[4 Oct 2023]
echo $PATH
echo %path%
echo $Env:Path
You need to know this so you can debug cases where the computer claims a command does not exist (maybe its folder isn't included in the path).
(you also need to know this so that you know how to use a computer... See The Missing Semester of Your CS Education from MIT.)
AppsAnywhere can be accessed on a lab machine by starting the Edge browser. Usually they're the first page that shows - if not, there should be a bookmark with that name.
Search "Eclipse" in the AppsAnywhere search field and start the one for C++.
Now, close any cmd (or powershell) window you may had opened to check your path and open a new one - check your path again; the folder should be present.
Type "g++ --version" - I get:
g++ (MinGW-W64 x86_64-msvcrt-posix-seh, built by Brecht Sanders) 13.2.0 Copyright (C) 2023 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.So, we now have access on the command line to a C++ compiler (g++), a debugger (gdb), and make (called mingw32-make).
The compiler and the debugger work out of the box but mingw32-make needs a bit of convincing to work correctly. The issue is that it thinks that it's installed in a different folder than it actually is (AppsAnywhere uses containers that probably explains this), so tries to find the compiler in there. For example, if I move into a directory that has file hello.cc and type "mingw32-make hello", I get:
>mingw32-make hello D:/Prog/winlibs64_stage/mingw64/bin/x86_64-w64-mingw32-g++.exe hello.cc -o hello process_begin: CreateProcess(NULL, D:/Prog/winlibs64_stage/mingw64/bin/x86_64-w64-mingw32-g++.exe hello.cc -o hello, ...) failed. make (e=2): The system cannot find the file specified. mingw32-make: *** [mingw32-make thinks that the compiler is "D:/Prog/winlibs64_stage/mingw64/bin/x86_64-w64-mingw32-g++.exe" but it isn't.: hello] Error 2 >
How can we tell it what the compiler is and where it'll find it? We can do so by adding a file called "Makefile" in our folder (where hello.cc exists). Running "mingw32-make hello" again should compile your file and produce an executable called "hello" (OK, this being Windows it'll be called "hello.exe"). You can execute it by typing (without the double quotes): ".\hello"
How did the Makefile solve the problem? It defined make's variable CXX, so that it points to the correct compiler, in the correct folder. It also defined make's variable CXXFLAGS, so that make knows what flags to pass to this compiler ("-g" is particularly important - it's needed to tell the compiler to add extra information that helps while debugging).
#includeSave the file (Contol-s), then select "Project -> Build All" (or just press Control-b), then press the Run button and choose "Local C/C++ Application".int main() { std::cout << "Hi!\n"; return 0; }
Remember to save your code before asking the IDE to re-build it.