Problem with gcc

This is a discussion on Problem with gcc within the Linux Programming forums, part of the Platform Specific Boards category; Hello all, when I tried to compile cpp program in linux my gcc compiler is showing following error >g++ 1.cpp ...

  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    10

    Unhappy What I have to do if I want to run Cpp program in linux


    Hello all,

    when I tried to compile cpp program in linux my gcc compiler is showing following error

    >g++ 1.cpp //after running this iam getting following messages

    *g++
    *pentium-builders
    *Try apt-get install <selected package>
    make sure you have the 'universe' component enabled
    bash: g++ command not found



    what exactly this mean
    I also tried to install new gcc version 4.3.0. After untaring that package I went through the instalation directory. According to confoguration maual I am supposed to follow the following steps.

    %mkdir objdir
    %cd objdir
    % ./srcdir/configure [options] [target]



    If I enterd the following command

    % ./configure --enable-cpp ./final/gcc_cpp



    I am getting following errors/warnings


    *Warning Should use --build --host -- target
    *Warning Invalid host type ./final/gcc_cpp
    Invalid configaration ./final/gcc_cpp



    I didn't undersatand what i did wrong there? Can any one please help me out from this

    All I want is to run Cpp programs on my Dell(i686) Computer and iam using Ubuntu Linux

    The GCC version Iam tring to install is 4.3.0


    Please help me


    Thanks
    Last edited by jayee_spicyguy; 10-20-2008 at 07:13 AM.

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,892
    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.
    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
    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]

  4. #4
    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.

  5. #5
    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]

  6. #6
    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.

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

  8. #8
    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.

  9. #9
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,892
    glibc-dev, most likely.

    Anyway, what happens when you type
    apt-get install gcc
    ?


    Also, are you clear about the difference between compiling and running a C program?
    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

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


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21