Thread: Problem with gcc

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    10
    Quote Originally Posted by CornedBee View Post
    Install gcc through apt-get. Don't try to install gcc manually - it can't work, because you need an existing C compiler, and you don't have one.
    [quick one]I am able to run C programs succesfully in gcc, that means I have C compiler is it is true? Is there any way to update my exixsting GCC so that it can compile both C and C++
    please advise.

    Thanks [/quick one]

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    gcc is the C compiler, g++ is the C++ compiler. In fact, it only matters when it comes to the final linking stage, where C++ code needs to use g++ - you can link C code with g++ too, but it may drag in a few extra bits that you didn't want/need. Otherwise, if you give gcc something that it thinks is C++, it will "do the right thing".

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Jul 2008
    Posts
    10
    Quote Originally Posted by matsp View Post
    gcc is the C compiler, g++ is the C++ compiler. In fact, it only matters when it comes to the final linking stage, where C++ code needs to use g++ - you can link C code with g++ too, but it may drag in a few extra bits that you didn't want/need. Otherwise, if you give gcc something that it thinks is C++, it will "do the right thing".

    --
    Mats
    [Question]Thanks for for you advise but I didn't understand why I am getting error when I tried to compile following file ?

    >>g++ 1.cpp
    g++ command is not found

    Please advise
    Thanks

    [/question]

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    You do not have a path to g++ - does gcc work?

    Edit: Just typing "gcc" should give you "no input files" or something like that.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    Jul 2008
    Posts
    10
    Quote Originally Posted by matsp View Post
    You do not have a path to g++ - does gcc work?

    Edit: Just typing "gcc" should give you "no input files" or something like that.

    --
    Mats
    Code:
     
    I wonder my gcc is also not working 
     I just realised that when I entered following code 
    
    
    #include <stdio.h>
    int main()
    {
    printf("hello");
    }
    
    
    I am getting stdio is not found and a warning stating my pintf declaration is wrong 
    
    That means I don't have C compiler installed is that is true? Now what I have to do Please advise 
    
    Thanks

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    If gcc works in the sense that it's not saying "gcc not found", then you have gcc - not sure how you end up with gcc but no g++ - perhaps they are in separate packages [I usually install a bunch of compiler stuff when I install a new Linux, and I can't quite remember what goes in which package]. The lack of stdio.h indicates that some other essential component. Not sure what package that comes as either...

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

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

Tags for this Thread