Question:
C++ compilers... need help!!!?
lyovlyov
2010-06-26 11:04:39 UTC
Hi everyone.
I have a .cpp file and I want to compile it using command line. Can anybody help me? I don't know how to do that.
And I would like to know what compilers I have installed on my PC, how can I find that out?

Thank you in advance!
Three answers:
jplatt39
2010-06-26 12:59:19 UTC
The two answers I just read are about GCC. I'm on linux so of course I use gcc. I also detest IDEs preferring the command line and the GNU DeBugger (gdb) gives you the ability to step through programs so I have given nothing up by avoiding them except those annoying project files whichh make compiling third party code so difficult.



I am not available to help but I would recommend getting someone to help you. GCC is actually part of the GNU tools and uses them, so you generally have to pick up the gnu tools to run them on Windows. One set of packages which gives you a fullly featured gcc is:



http://www.mingw.org



MinGW (Minimalist GNU for Windows) requires you to download and unzip a lot of files into a directory or folder at the top level of your os so it would be, say, c:\mingw then add c:\mingw to your %PATH variable. You will find instructions and a batch file to help you at their website. It looks scarier than it is which is why I suggested get some help/



In point of fact though both Visual C++ and Turbo C++ have command line compilers, (cl.exe and tcc.exe or bcc.exe for borland c++ respectively). Windows does not install a compiler by default so if you didn't install one you have to. Again MinGW is a good choice and this is a good web page to look at other choices.



http://www.freeprogrammingresources.com/cppcomp.html
eli porter
2010-06-26 18:15:40 UTC
if you don't have linux, you do not have a compiler installed on your computer. On a mac.. I'm not sure but maybe.



for FREE you can try GCC: http://gcc.gnu.org/

altho probably easier to get this copy (if ur on windows): http://www.mingw.org/



if you are in windows, you would compile it like this:

g++ -o hello.exe hello.cpp



but I recommend getting an IDE for windows that will do this behind the scenes, windows has a terrible and weak command line interface.
anonymous
2010-06-26 18:28:19 UTC
Most Linux distros come with G++, so just open a terminal and type "g++ hello.cpp" and run using "./a.out". Replace g++ with gcc if it's a C program.



If you're using Windows, you can install g++ for windows and do the same with the command prompt.



For Mac, I'm not sure. G++ is quite common for anything Unix-based, so it should be already on the OS, but it can be installed if not.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Continue reading on narkive:
Loading...