Force gcc to use one linker over another
Lately I have been working on OS X. Things were going pretty peachy for a while until somehow ld
got on my system and now gcc
won't use dyld
. Furthermore, all of my shared libraries are in *.dylib
format, and ld i开发者_如何学JAVAs stubornly ignoring there existance. If I mv
ld from PATH
, gcc just complains it cant find ld.
Please help me to get gcc back on track and using what it should.
You can try some gcc options. From the man page:
-c Compile or assemble the source files, but do not link. The linking stage simply is not done. The ultimate output is in the form of an object file for each source file.
You could then link explicitly using whatever linker you want.
Does it help to symlink ld to dyld?
mv /usr/bin/ld /usr/bin/ld.old
ln -s /usr/bin/dyld /usr/bin/ld
Edit: fixed ld params order
This isn't your exact question, but I had a need to switch to ld.gold
, and for that, the -fuse-ld=gold
option to gcc was very useful.
look at -Xlinker
option
I got it from man gcc
you can double check using some verbose options like -v
精彩评论