Debian-Etch and GCC 4.1

This is a discussion on Debian-Etch and GCC 4.1 within the C++ Programming forums, part of the General Programming Boards category; Am I doing something wrong with Linux. I was doing a tutorial online dealing with sockets and the tutorial was ...

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

    Debian-Etch and GCC 4.1

    Am I doing something wrong with Linux. I was doing a tutorial online dealing with sockets and the tutorial was specific to Linux sockets and the code didn't compile. This is the first time I've tried to do any programming on this machine. It's running Etch (Debian), which i guess *might* be an issue? But what I am doing wrong? Some of the things I can't do are:

    std stuff such as:
    std::cout << "whatever";

    it says "error: 'cout' is not a member of 'std'

    and like when i comment out the cout statement it gives me a huge list of undefined references to the classes functions that I have linked in. I have to be nub-ing something up. Can anyone help me?

  2. #2
    Registered User
    Join Date
    Jan 2007
    Posts
    10

    I got hello world working

    ok i got hello world working...but i had to use "using namespace std;"

    do i have to use namespace std on linux????

  3. #3
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Recreate the problem with as little code as possible then post here. My crystal ball is recharging today so I can't use that to divinate your problems.

    EDIT:

    C++ is C++ no mater the platform. And
    Code:
    using namespace std;
    should only be used in cases of making old programs work without having to completely go through and add the std:: to the beginning of each std class. The prefered method is
    Code:
    std::cout
    Last edited by Wraithan; 01-12-2007 at 06:58 PM.

  4. #4
    Registered User
    Join Date
    Jan 2007
    Posts
    10

    recreation: recreate.cpp simple test

    //this is the code
    Code:
    #include <iostream>
    
    int main()
    {
            std::cout<<"testing";
            return 0;
    }

    //compile line = gcc recreate.cpp

    //this is the errors
    Code:
    /tmp/ccmpnhEB.o: In function `__static_initialization_and_destruction_0(int, int)':
    recreate.cpp:(.text+0x23): undefined reference to `std::ios_base::Init::Init()'
    /tmp/ccmpnhEB.o: In function `__tcf_0':
    recreate.cpp:(.text+0x66): undefined reference to `std::ios_base::Init::~Init()'
    /tmp/ccmpnhEB.o: In function `main':
    recreate.cpp:(.text+0x76): undefined reference to `std::cout'
    recreate.cpp:(.text+0x7b): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
    /tmp/ccmpnhEB.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
    collect2: ld returned 1 exit status

  5. #5
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    gcc is a C compiler, you want g++.

  6. #6
    Registered User
    Join Date
    Jan 2007
    Posts
    10
    lol that helps...i knew it was something nub-ish. Thanks for the help

  7. #7
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Since you are in Linux always keep in mind you have the man pages to look at, they will be your best friend while you get aquinted to your new system.

  8. #8
    Registered User
    Join Date
    Jan 2007
    Posts
    10

    Thanks!

    yea, I used the man pages some, just not enough evidently lol. i'm not really new to linux, just programming c++ on linux. anyway thanks for the help. Portland Or rocks. My family is from Canby, OR....Corvalis, OR....Eugene, OR....Medford, OR....Salem, OR.....lol pretty much just Oregon

Popular pages Recent additions subscribe to a feed

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