View Full Version : problem with GCC

12-26-2007, 11:06 PM

I have the problem in using GCC compiler....

I have wrote a simple program in C++ but when I run the command :

gcc -o hello.cpp

It gives following error:

gcc: no input files

I have wrote the code in Kdevelop and I am using Slackware OS and also I have compiled

the code in correct directory.

One more thing,when I run the command :

gcc -o hello.cpp

It runs properly and produced hello.o file.

12-27-2007, 03:39 AM
1) There is no difference between the two commands you posted.
2) Use g++ to compile C++ code. It will automatically link against the C++ runtime libraries.
3) The -o option is given the name for the output file, which is the next argument. So your command says, "The output filename is hello.cpp, and take all other files and compile and link them into the executable give by the output filename". But there are no other files. If you just want to compile, the flag you want is -c, not -o.

12-27-2007, 04:12 PM
In other words, to compile:

g++ hello.cpp -o hello
To execute:

However, you should be able to get KDevelop to compile and execute the code for you. Let me see, I'll launch KDevelop. Click on Project->Close Project, if you already have one open. Click on Project->New Project. Expand C++, click on Simple Hello World Program. Accept, accept, etc.

That gives you a project with tons of files you don't need, such as Doxyfile and COPYING etc.

Ah well. Maybe the command line is the best bet. That's what I use anyway. ;)