'Undefined symbols' when using std c++ libraries

Discussion in 'Mac Programming' started by sammich, Apr 12, 2010.

  1. sammich macrumors 601

    sammich

    Joined:
    Sep 26, 2006
    Location:
    Sarcasmville.
    #1
    In something as simple as:
    Code:
    #include <iostream>
    using namespace std;
    
    int main() {
    	return 0;
    }
    I get a list of the undefined symbols bookended by "ld: symbol(s) not found". I am compiling using just gcc -o test test.cc, something which has worked in the past.

    I have XCode 3.2 (1610) installed. And making a project as a CLI tool (10.6) and building it works.

    And preferably I'd like to keep from downloading XCode all over again as I don't exactly have a that much bandwidth for the month to spare.

    What happened? I haven't used C++ in a while as I was doing a course that required straight C so I don't know where things stopped working.
     
  2. sammich thread starter macrumors 601

    sammich

    Joined:
    Sep 26, 2006
    Location:
    Sarcasmville.
    #2
    Updated my post above:

    Building the code as a CLI tool in XCode as a 10.6/10.5 executable works without a hitch.

    So are there some extra arguments that I need to give to gcc to get it to compile properly?
     
  3. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #3
    Are you sure you are compiling it right?

    Code:
    g++ test.cpp -o test
     
  4. sammich thread starter macrumors 601

    sammich

    Joined:
    Sep 26, 2006
    Location:
    Sarcasmville.
    #4
    Ouch. You can can really tell I've been away from C++ for too long and attached to C.

    Thanks for not mocking me :)
     

Share This Page