Csharp:
On many systems the "csharp-mono" environment is prepackaged by the system developers and can be easily install by the system's package manager:• Debian based systems:
sudo apt install mono-mcs(there are also "mono-devel" and "mono-complete" packages, but it seems that "mono-mcs" is enough for us).
• Termux:
apt install mono
• MacOS,
brew install monoIf that fails, you might need to install mono from the mono-poject,
[https://www.mono-project.com/download/stable/#download-mac],
C++
There are two major open implementations of C++: "g++" and "clang".• Debian based systems:
sudo apt install g++
sudo apt install clang• Termux:
apt install clang• MacOS: it seems that clang is included in Xcode.
Create a directory for the exercise inside your repository, let's say "~/repos/ppnm/exercises/hello",
mkdir -p ~/repos/ppnm/exercises/hello
Go to your directory (remember to use the completion feature of your shell !):
cd ~/repos/ppnm/exercises/hello
Makefile
with the following content (mind
the tabulators!) (and you can omit the comments).
Out.txt : hello.exe # Out.txt depends on hello.exe mono hello.exe > Out.txt # run hello.exe, send output to Out.txt hello.exe : hello.cs # hello.exe depends on hello.cs mcs hello.cs # compile hello.cs, save bytecode in hello.exe clean: # a phoney target, no dependencies rm -f Out.txt hello.exe # remove secondary files• Makefile for C++:
Out.txt : hello.exe # Out.txt depends on hello.exe ./hello.exe > Out.txt # run hello.exe, send output to Out.txt hello.exe: hello.cc # hello depends on hello.cc clang++ -o hello.exe hello.cc # compile-and-link hello.cc, save executable in hello.exe clean: rm -f Out.txt hello.exe
hello.cs
(hello.cc
) with
the following content,
class hello{ static int Main(){ System.Console.Write("hello\n"); return 0; } }• hello.cc:
#include<iostream> /* std::cout */ #include<stdio.h> /* printf */ int main(){ std::cout << "Hello, "; printf("World!\n"); return 0; }
make
" and debug.
~/.nanorc
"
file,
syntax "makefile" "[Mm]akefile" color white,magenta " "where the character in between the quotation marks in the second line should be the tabulator sign and where the colors are free for you to choose.
Alternatively, you can enable makefile syntax highlighting by adding
the following line to your "~/.nanorc
" file,
include /usr/share/nano/makefile.nanorc
If you use GNU make version 3.82+ and you don't like your recipies
to start with the tabulator-sign, you can do
.RECIPEPREFIX := ;