Thread: problem with GCC

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    113

    problem with GCC

    Hi,

    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.
    Thanks

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    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.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    In other words, to compile:
    Code:
    g++ hello.cpp -o hello
    To execute:
    Code:
    ./hello
    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.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Quick Compilation Question
    By chacham15 in forum C Programming
    Replies: 10
    Last Post: 10-12-2008, 08:15 PM
  2. Profiler Valgrind
    By afflictedd2 in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2008, 09:38 AM
  3. Replies: 4
    Last Post: 09-02-2007, 08:47 PM
  4. searching problem
    By DaMenge in forum C Programming
    Replies: 9
    Last Post: 09-12-2005, 01:04 AM
  5. Bin packing problem....
    By 81N4RY_DR460N in forum C++ Programming
    Replies: 0
    Last Post: 08-01-2005, 05:20 AM