# OSX CLI compilation woes

This topic is 4275 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Somewhere along the line, I lost the ability to compile my projects (using Makefiles and g++, 'cause I like commandlines). They fail with the following output:
g++ -g -Wall -pedantic -Iinclude -I/usr/local/include/SDL -bind_at_load -o game main.o sprite.o coord.o generic.o animation.o
world.o layer.o listener.o box.o spritetree.o polygon.o line.o -L/usr/local/lib
-framework Cocoa -framework OpenGL -lSDLmain -lSDL -lSDL_image -lSDL_draw
-llua -llualib -lvcontrol -lstdc++
ld: world.o illegal reference to symbol:
std::_Rb_tree_rotate_left(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*&)
defined in indirectly referenced dynamic library /usr/lib/libstdc++.6.dylib
make: *** [game] Error 1
Now, that seems to imply that my standard libraries got horked somehow. I've downloaded XTools 1.5 from the Apple website (I can't use the 2.0+ versions because they're OS 10.4 only, and I'm running 10.3), but it refuses to do a clean install; I can only "Upgrade" my components. This, sadly, does not result in a replacement of my stdlibs - the CLI tools "upgrade" is 0KB in size. Presumably it's checking for the existence but not the integrity of my libraries. Does anyone know how I might go about fixing this problem? Is my diagnosis even correct? I'm decent at programming, but my knowledge of how libraries work is sketchy at best. Google searches reveal that people who installed Google Earth had similar problems, but I haven't installed that program. The only thing significant I've installed lately is Blender, but it's been long enough since I tried working on my coding projects that I can't say for certain if it was Blender that broke things. [Edited by - Derakon on April 2, 2006 1:34:14 AM]

##### Share on other sites
Assuming you meant -l/usr/lib/libstdc++ (that's a lowercase 'L'), I just get "ld: can't locate file for: -l/usr/lib/libstdc++.6.dylib". Or for any of the variations on the name that I think it would want (e.g. leaving off the ".dylib" and/or the ".6". If I actually just put "/usr/lib/libstdc++.6.dylib" as an argument then make doesn't work and spews out some 1816 lines of error output, some of which I've copied below:
g++ -g -Wall -pedantic -Iinclude -I/usr/local/include/SDL
-I/usr/lib/ -bind_at_load -o game main.o sprite.o coord.o generic.o animation.o
world.o layer.o listener.o box.o spritetree.o polygon.o line.o -L/usr/lib
-L/usr/local/lib -framework Cocoa -framework OpenGL -lSDLmain -lSDL
-lSDL_image -lSDL_draw -llua -llualib -lvcontrol -lstdc++ /usr/lib/libstdc++.6.dylib
ld: warning multiple definitions of symbol std::wcout
/usr/lib/libstdc++.a(globals.o) private external definition of std::wcout in section (__DATA,__data)
/usr/lib/libstdc++.6.dylib(single module) definition of std::wcout
ld: warning multiple definitions of symbol std::wclog
/usr/lib/libstdc++.6.dylib(single module) definition of std::wclog
ld: warning multiple definitions of symbol std::wcerr
/usr/lib/libstdc++.a(globals.o) private external definition of std::wcerr in section (__DATA,__data)
/usr/lib/libstdc++.6.dylib(single module) definition of std::wcerr
ld: warning multiple definitions of symbol std::wcin
/usr/lib/libstdc++.a(globals.o) private external definition of std::wcin in section (__DATA,__data)
/usr/lib/libstdc++.6.dylib(single module) definition of std::wcin
ld: warning multiple definitions of symbol std::cout
/usr/lib/libstdc++.a(globals.o) private external definition of std::cout in section (__DATA,__data)
/usr/lib/libstdc++.6.dylib(single module) definition of std::cout
ld: warning multiple definitions of symbol std::clog
/usr/lib/libstdc++.6.dylib(single module) definition of std::clog
ld: warning multiple definitions of symbol std::cerr

That...looks like a problem.

##### Share on other sites
Quote:
 Original post by DerakonAssuming you meant -l/usr/lib/libstdc++ (that's a lowercase 'L'), I just get "ld: can't locate file for: -l/usr/lib/libstdc++.6.dylib". Or for any of the variations on the name that I think it would want (e.g. leaving off the ".dylib" and/or the ".6".

No, I did mean without the -l.

Quote:
 If I actually just put "/usr/lib/libstdc++.6.dylib" as an argument then make doesn't work and spews out some 1816 lines of error output, some of which I've copied below:*** Source Snippet Removed ***That...looks like a problem.

Hmm. Maybe try removing -lstdc++.

##### Share on other sites
Well, regressing to the old days of counting the errors, that gets me down to 37 lines of error output, which I've copied below:

g++ -g -Wall -pedantic -Iinclude -I/usr/local/include/SDL -I/usr/lib/
-bind_at_load -o game main.o sprite.o coord.o generic.o animation.o
world.o layer.o listener.o box.o spritetree.o polygon.o line.o -L/usr/lib
-L/usr/local/lib -framework Cocoa -framework OpenGL -lSDLmain -lSDL
-lSDL_image -lSDL_draw -llua -llualib -lvcontrol /usr/lib/libstdc++.6.dylib
ld: multiple definitions of symbol std::allocator<char>::allocator(std::allocato
r<char> const&)
/usr/lib/libstdc++.6.dylib(single module) definition of std::allocator<char>::al
locator(std::allocator<char> const&)
/usr/lib/libstdc++.a(stl-inst.o) private external definition of std::allocator<c
har>::allocator(std::allocator<char> const&) in section (__TEXT,__text)
ld: multiple definitions of symbol std::allocator<char>::allocator()
/usr/lib/libstdc++.6.dylib(single module) definition of std::allocator<char>::al
locator()
/usr/lib/libstdc++.a(stl-inst.o) private external definition of std::allocator<c
har>::allocator() in section (__TEXT,__text)
ld: multiple definitions of symbol std::allocator<char>::allocator(std::allocato
r<char> const&)
/usr/lib/libstdc++.6.dylib(single module) definition of std::allocator<char>::al
locator(std::allocator<char> const&)
/usr/lib/libstdc++.a(stl-inst.o) private external definition of std::allocator<c
har>::allocator(std::allocator<char> const&) in section (__TEXT,__text)
ld: multiple definitions of symbol std::allocator<char>::allocator()
/usr/lib/libstdc++.6.dylib(single module) definition of std::allocator<char>::al
locator()
/usr/lib/libstdc++.a(stl-inst.o) private external definition of std::allocator<c
har>::allocator() in section (__TEXT,__text)
ld: multiple definitions of symbol std::allocator<char>::~allocator()
/usr/lib/libstdc++.6.dylib(single module) definition of std::allocator<char>::~a
llocator()
/usr/lib/libstdc++.a(stl-inst.o) private external definition of std::allocator<c
har>::~allocator() in section (__TEXT,__text)
ld: multiple definitions of symbol std::allocator<char>::~allocator()
/usr/lib/libstdc++.6.dylib(single module) definition of std::allocator<char>::~a
llocator()
/usr/lib/libstdc++.a(stl-inst.o) private external definition of std::allocator<c
har>::~allocator() in section (__TEXT,__text)
ld: multiple definitions of symbol std::allocator<wchar_t>::allocator(std::alloc
ator<wchar_t> const&)
/usr/lib/libstdc++.6.dylib(single module) definition of std::allocator<wchar_t>:
:allocator(std::allocator<wchar_t> const&)
/usr/lib/libstdc++.a(stl-inst.o) private external definition of std::allocator<w
char_t>::allocator(std::allocator<wchar_t> const&) in section (__TEXT,__text)
ld: multiple definitions of symbol std::allocator<wchar_t>::allocator()
/usr/lib/libstdc++.6.dylib(single module) definition of std::allocator<wchar_t>:
:allocator()
/usr/lib/libstdc++.a(stl-inst.o) private external definition of std::allocator<w
char_t>::allocator() in section (__TEXT,__text)
ld: multiple definitions of symbol std::allocator<wchar_t>::allocator(std::alloc
ator<wchar_t> const&)
/usr/lib/libstdc++.6.dylib(single module) definition of std::allocator<wchar_t>:
:allocator(std::allocator<wchar_t> const&)
/usr/lib/libstdc++.a(stl-inst.o) private external definition of std::allocator<w
char_t>::allocator(std::allocator<wchar_t> const&) in section (__TEXT,__text)
ld: multiple definitions of symbol std::allocator<wchar_t>::allocator()
/usr/lib/libstdc++.6.dylib(single module) definition of std::allocator<wchar_t>:
:allocator()
/usr/lib/libstdc++.a(stl-inst.o) private external definition of std::allocator<w
char_t>::allocator() in section (__TEXT,__text)
ld: multiple definitions of symbol std::allocator<wchar_t>::~allocator()
/usr/lib/libstdc++.6.dylib(single module) definition of std::allocator<wchar_t>:
:~allocator()
/usr/lib/libstdc++.a(stl-inst.o) private external definition of std::allocator<w
char_t>::~allocator() in section (__TEXT,__text)
ld: multiple definitions of symbol std::allocator<wchar_t>::~allocator()
/usr/lib/libstdc++.6.dylib(single module) definition of std::allocator<wchar_t>:
:~allocator()
/usr/lib/libstdc++.a(stl-inst.o) private external definition of std::allocator<w
char_t>::~allocator() in section (__TEXT,__text)

So what is this "/usr/lib/libstdc++.a(stl-inst.o)", do I need it, and if not, how do I get rid of it safely?

EDIT: commentary from someone on another forum: "Since you're using XCode 1.5, you're using gcc 3.3 (or at least, not 4.0). So it shouldn't be using libstdc++.6.dylib, but the static version libstdc++.a, try to put it in your project/explicitely specify it in the makefile and it could solve the problem. Otherwise I don't know what it could be."

So I tried that (explicitly invoking the static version), but then I'm just back where I started with an illegal reference to something in the dylib. So somehow, one of my other libraries is invoking the dylib and thereby causing my compiler to choke. Is there a way I can determine which library is doing this and stop it somehow?

[Edited by - Derakon on April 2, 2006 1:58:34 PM]

##### Share on other sites
Just a guess here, but try not short-circuiting the compiler by explicitly linking in the C++ standard libarry. If you invoke GCC using the 'g++' driver, it automatically pulls in the standard libarry (and the rest of the C++ runtime libraries) from the right place. If you start adding them explicitly to the command line, you could end up pulling in a different version that's not ABI-compatible.

##### Share on other sites
Bregma: that's what I was doing originally. Something else that I'm linking in is referring to the dynamic library, causing ld to choke. My g++/ld skills are not to the point where I can figure out even what ld is being asked to do, as it's invoked by g++; otherwise I might have some clue how to tell ld to not use dynamic libraries or something similar. I don't want dynamic linking anyway, as I eventually want to be able to distribute this as a standalone program (including all of the libraries it needs in the package).

##### Share on other sites
Quote:
 Original post by DerakonSomething else that I'm linking in is referring to the dynamic library, causing ld to choke.

Could it be one of the frameworks or explicit dylibs you're pulling in were built for 10.4?

You could always add a "-Wl,-M" to the g+++ command line to force ld to spew a linkmap. It does it to stdout, so redirect output into a log.

I'm assuming you're actually instantiating a std::map of some description in world.cpp.

##### Share on other sites
Yes, I am using maps in world.cpp. Adding the suggested arguments to my g++ flags just gets me a lot of "linker input file unused because linking not done" - one for each .o file and -l library, and one for libstdc++.a, of course. The invocation now looks like this:
g++ -g -Wall -pedantic -Iinclude -I/usr/local/include/SDL -bind_at_load
-Wl -M -o game main.o sprite.o coord.o generic.o animation.o world.o layer.o
listener.o box.o spritetree.o polygon.o line.o -L/usr/lib -L/usr/local/lib
-framework Cocoa -framework OpenGL -lSDLmain -lSDL -lSDL_image -lSDL_draw
-llua -llualib -lvcontrol /usr/lib/libstdc++.a

I feel like this is turning into Remedial Makefiles. Feel free to tell me to go read through the documentation if you think it'd help.

##### Share on other sites
[quote]Original post by Derakon
-Wl -M

Make sure it's -Wl,-M with no space and with a comma. It's a passthrough arg to ld.
Quote:
 I feel like this is turning into Remedial Makefiles. Feel free to tell me to go read through the documentation if you think it'd help.

Ah, no, I've read it. It doesn't seem to help.

Have you used otool on all the dylibs (including the ones on the frameworks) to check what version of libstdc++ they were built with?

##### Share on other sites
Ahh, sorry; I thought you were specifying two different arguments. However, I get precisely no change in output when I put them in as you suggested. Very strange. I'm using g++ 3.3, for reference.

Fiddling around with otool doesn't reveal any way I can tell which version of the C standard libs my libraries were built with. I might be able to manually determine which library is linking in the dylib though.

##### Share on other sites
Hah! Turns out there was a conflict with Quicktime 7.0.4. I'd initially discounted this as a possibility because Software Update informed me that my last installed version was 7.0.3, installed last November. But it turns out that 7.0.4 wormed its way in somehow on Feb 19th. One quick downgrade later, and I'm back in business. Excellent.

Thanks for the assistance, everyone. If nothing else, I'm a bit more familiar with libraries now.

##### Share on other sites

This topic is 4275 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628726
• Total Posts
2984408

• 25
• 11
• 10
• 16
• 14