Problem running g++ from terminal window

Joined
Mar 30, 2012
Messages
2
Reaction score
0
Points
1
I have this infuriating problem; I'm trying to compile a simple example from Stroustrup's book on C++:

g++ char.gpp -o char

I get the following error:

ld: library not found for -lcrt1.10.6.o
collect2: ld returned 1 exit status

So, I found where crt1.10.6.o is, and set LIBRARY_PATH to:

/Developer/SDKs/MacOSX10.6.sdk/usr/lib

and then the compile step gives:

ld: warning: in char.gpp, file was built for unsupported file format which is not the architecture being linked (x86_64)
Undefined symbols:
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

This is in Lion with the latest Xcode newly installed. The library crt1.10.6.o seems to be the issue.

Failing that, is there a way to run the Xcode to generate a command-line executable?
 
Joined
Aug 13, 2011
Messages
200
Reaction score
7
Points
18
Location
West Sussex
I'm running Xcode 4.2, and there is a command line tool project template in the Mac OSX applications category, when starting a new project from the file menu.
But I dont know if this template is still available in the latest 4.3 version of Xcode, I would find it hard to
believe, they have ditched this template in the latest release of Xcode.

So if the command line tool project template is still available, then thats what I would, and have used previously.

Sorry I could not be more help.

Regards Mark
 
OP
K
Joined
Mar 30, 2012
Messages
2
Reaction score
0
Points
1
I've figured out one thing: the file should probably have ".cc" rather than ".gpp" as the suffix. I guess .gpp refers to a preprocessed file.

So then the problem becomes:

char.cc:1:20: error: iostream: No such file or directory

Header files are in the /Developer/SDKs/.... but I would expect the compiler to know where to find these files.

So I'm not quite there. I'd appreciate any help; I'd really like to compile files from the terminal while practicing C++ coding.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top