Hi, I am just starting to learn c++, but the book I am learning from only suggests windows compilers. The compiler needs to be able to compile .cpp files so they can be run under ubuntu 8.10.
All help appreciated :D
Archived thread 1016741 from Packaging and Compiling Programs. Markdown source: Packaging_and_Compiling_Programs/thread_1016741_Looking_for_a_C++_compiler.md
Hi, I am just starting to learn c++, but the book I am learning from only suggests windows compilers. The compiler needs to be able to compile .cpp files so they can be run under ubuntu 8.10.
All help appreciated :D
Ubuntu has a C++ compiler built in by default.
Assuming you have a file called main.cpp use this command line:
g++ main.cpp -Wall -o main
Hope it helps you!
jpmelos said: Ubuntu has a C++ compiler built in by default.
Assuming you have a file called main.cpp use this command line:
g++ main.cpp -Wall -o main
Hope it helps you!
To add to that, it may help to know what's going on with this command.
*g++*: the program name. *main.cpp*: your file you are trying to compile *-Wall*: a "flag" (an indicator) to G++ to print all warnings. *-o*: a flag that says, "make the executable to the name provided." *main*: the generated executable.
To run your newly-created executable, simply run the command line:
./main
Assuming you used cout or printf, it'll print in the terminal your output.
Not sure if it is in there by default you might need to install build-essential.
Thanks a lot guys, that works a treat :)
David,
Just remember if you book is making MS Windows API calls they will not compile on the Ubuntu System. Start of by making only POSIX compliant and Standard C++ function calls. This will get you the basics of what you need to accomplish.
Other Libraries of note which I use: Poco Boost glib
Ubuntu Windowing API's which I use: wxWidgets
For C++ programming, I personally recommend, "The C++ Programming Language" by Bjarne Strousstrupp
For wxWidgets programming, I personally recommend, "Cross-Platform GUI Programming with wxWidgets" by Smart and Hock.
Libraries like poco, boost and glib, posix and std::C++ can be cross compiled to different hardware architectures very easily... i.e. X86 to ARM-9 for example. And I don't need to change my code to make them work on the different architecture. [there are some caveats of course... ]
Hope this helps!