|Apr 10, 2008, 12:03 AM||#1|
Linker (ld) problems
I'm having a weird problem with the linker I cannot explain. Before filing it as a possible bug, I'd like to have your opinion on that.
I'm building an executable (command-line) that requires some external libraries.
Let's say I need to link (statically) with:
The external libraries (are given (to ld) by XCode using the form:
-lfoo -lbar -lfoo++ -lbar++
The problem: ld reports a bunch of unresolved symbols.
If I invoke by hand ld by specifying the static libs directly as input files instead of libraries everything works fine:
ld ... /usr/local/lib/libfoo.a /usr/locallib/libbar.a /usr/local/lib/libfoo++.a /usr/local/lib/libbar++.a
If you want to reproduce it, download the xmlrpc-c library from Sourceforge
(xmlrpc-c.sourceforge.net), build it and install it under /usr/local and try to build one of the example first using the form that uses the -l<lib> flag, and then with the other form.
In my case I also discovered that ONLY ONE library needs to be listed using /usr/local/lib/<blah>.a...
To be more specific, this is *NOT* working:
ld <...> -lxmlrpc++ -lxmlrpc_server_abyss++ -lxmlrpc_server++ -lxmlrpc_server_abyss -lxmlrpc_server -lxmlrpc_abyss -lxmlrpc_util -lxmlrpc_xmlparse -lxmlrpc_xmltok -lxmlrpc
and this IS WORKING:
-lxmlrpc++ -lxmlrpc_server_abyss++ -lxmlrpc_server++ -lxmlrpc_server_abyss -lxmlrpc_server -lxmlrpc_abyss -lxmlrpc_util -lxmlrpc_xmlparse -lxmlrpc_xmltok /usr/local/lib/xmlrpc.a
Weird isn't it?
Am I missing something?
Is it really a bug ?
Thanks for your opinion.
|Apr 10, 2008, 04:07 AM||#2|
I may be totally wrong here but, but it looks you only need /usr/local/lib/xmlrpc.a for linking. The -lx is shorthand for /usr/local/lib/libx.a. So looking at the two examples, the first is linking to non existing libraries, while the second is linking to /usr/local/lib/xmlrpc.a.
b e n
EDIT: It just occurred to me that the 1st line doesn't work because it's trying to link to /usr/local/lib/libxmlrpc.a which doesn't exist, hence the reason why the 2nd line works.
Last edited by lazydog; Apr 10, 2008 at 09:41 AM.
|Apr 10, 2008, 10:11 AM||#3|
My bad... In my second example I was meant to put /usr/local/lib/libxmlrpc.a
Right now I have my Xcode project that list all the external library in the project, *BUT* the libxmlrpc.a is listed in the "Other linker flags"...
In conclusion it really seems to me the linker is really doing something wrong...
|Feb 17, 2009, 03:41 PM||#4|
fabrizi0, did you ever get this resolved? I am trying to port some existing code that makes fine under Solaris and Linux, but I am getting similar linker errors. What did you ever figure out?
|Feb 18, 2009, 09:03 AM||#5|
Well, I have not tried to re-use the same feature as I have found a workaround.
Instead of listing the libraries in the project, I'm adding (manually) all my dependencies to the linker command line, through the line "Other Linker Settings".
This solution not only fixes my problem, but it also allow me to specify different libraries for different configuration (Debug/Release).
|Feb 18, 2009, 04:48 PM||#6|
We found our problem; one of our libraries happens to have the same name as a system library and ld for MacOS apparently searches for libraries differently than Solaris and Linux. Here is a link to another forum that gives some info: http://discussions.apple.com/thread....readID=1713972
We resolved our problem by renaming our library. Since we are trying to maintain the same source and build process across multiple platforms, this was the easiest and most universal solution.
Thanks for your help.
|Thread Tools||Search this Thread|
|thread||Thread Starter||Forum||Replies||Last Post|
|Mach-O Linker Error: Duplicate Symbols||moonman239||iPhone/iPad Programming||5||Oct 21, 2013 09:08 PM|
|RMBP 15" - Problems problems and more problems||rmwebs||MacBook Pro||14||Sep 30, 2013 04:22 AM|
|Linker command failed with exit code 1||adildacoolset||iPhone/iPad Programming||2||Feb 15, 2013 06:00 AM|
|Linker Command Failed Error, Please Help||loon3y||iPhone/iPad Programming||2||Sep 26, 2012 05:20 PM|
|Linker Command Failed With Exit Code 1?||loon3y||iPhone/iPad Programming||2||Sep 5, 2012 06:10 PM|
All times are GMT -5. The time now is 11:51 PM.