compilation on osX: linking errors with libxml2

Questions about Anatomist manipulation

Moderators: denghien, riviere

Post Reply
Guidon
Posts: 23
Joined: Fri Mar 25, 2005 9:34 pm
Location: Rochester, New York, USA
Contact:

compilation on osX: linking errors with libxml2

Post by Guidon »

Hi all,

I am trying to compile the development version of aimsdata on mac osx using this command line:

Code: Select all

build-config --build aimsdata 
Compiling the objects works fine but the linking fails due to some confusion between two packages of libxml2 installed independentlly on my system. One probably came with the os and the other one (2.6.7) was placed in /sw/lib by fink. Here is a sample of what the linking error reads like:

Code: Select all

[...]
symbol _libiconv_relocate used from dynamic library /usr/lib/libiconv.2.dylib(relocatable.o) not from earlier dynamic library /sw/lib/libiconv.2.dylib(relocatable.o)
symbol _libiconv_set_relocation_prefix used from dynamic library /usr/lib/libiconv.2.dylib(relocatable.o) not from earlier dynamic library /sw/lib/libiconv.2.dylib(relocatable.o)
[...]
I tried to pass along the version number thinking that it would compile against the preferred version installed by fink:

Code: Select all

build-config --build aimsdata libxml2 --version 2.6.7
But same thing happened. How can I work around that problem with respect to the logic of build-config? Shall I set a symbolic link pointing to the right lib under /sw ? Did you encounter this on mac before?
I would be glad if I could keep the fink libxml2 because other applications depend on it (gtk...).

Thanks for your help.
Kind Regards,

Arnaud Guidon, Rochester NY
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Post by riviere »

Hi,

Well, I was just not using libxml2 from fink but the standard /usr/lib/libxml2...
The problem is that up to now, libiconv was not a known element of build-config (on linux it seems to be part of glibc), so build-config takes care of forcing linking against the selected libxml2 and lets the system do the rest. But the system is quite stupid and probably tries to link against /usr/lib/libiconv.dylib even if libxml2 is linked against a hard-coded path /sw/lib/libiconv.dylib (I hold a great grudge against the various versions of Apple linkers).

I'll try to see if adding a "-liconv" juste after "-lxml2", or if forcing the same path as libxml2 is enough.

In the meantime, maybe you could try setting the DYLD_LIBRARY_PATH environment variable to include /sw/lib. I don't know if it would have any effect at link-time, but it's worth trying because I know Fink doesn't set it in its config but rather hard-codes all libraries paths, so by default /sw/lib is not searched at all in system libraries paths (when executing programs, at least).

Denis
Last edited by riviere on Wed Apr 13, 2005 9:49 pm, edited 1 time in total.
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Post by riviere »

Well, you can try this updated build-config, it explicitely links against libiconv.Tell me if it helps or not (I have not tested it myself using fink libxml2).
Denis
Guidon
Posts: 23
Joined: Fri Mar 25, 2005 9:34 pm
Location: Rochester, New York, USA
Contact:

Post by Guidon »

Thank you Denis,

It finally compiled without linking warnings but I can't tell whether it was as a result of adding /sw/lib to the $DYLD_LIBRARY_PATH or just the fact of removing libxml2 from sw. In fact the command below shows that the binaries are linked to /usr/lib/libxml2.2.dylib which is what I want if I get it right.

Code: Select all

otool -L AimsFlip 
AimsFlip:
        libaimsdata-debug.dylib.2.14 (compatibility version 0.0.0, current version 0.0.0)
        libgraph-debug.dylib.1.17 (compatibility version 0.0.0, current version 0.0.0)
        libcartodata-debug.dylib.3.0 (compatibility version 0.0.0, current version 0.0.0)
        libcartobase-debug.dylib.1.2 (compatibility version 0.0.0, current version 0.0.0)
        /usr/local/lib/libsigc-2.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
        /usr/lib/libxml2.2.dylib (compatibility version 9.0.0, current version 9.7.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 71.1.1)
However, another error persists which I hadn't mentioned before:

Code: Select all

dyld: ./AimsFlip can't open library: libaimsdata-debug.dylib.2.14  (No such file or directory, errno = 2)
Trace/BPT trap
...And so on for the other libraries that the build just created. I stop having this error when I add all the *-main-default/lib to DYLD_LIBRARY_PATH but then I get a segmentation fault when I try running any of the binaries.

I'm well aware that this problem is likely due to my system rather than the building tool itself so I appreciate that you help me resolve issues that are not directly linked to brainvisa.
Kind Regards,

Arnaud Guidon, Rochester NY
Guidon
Posts: 23
Joined: Fri Mar 25, 2005 9:34 pm
Location: Rochester, New York, USA
Contact:

Post by Guidon »

Oops I hadn't seen your answer. I'll give a try to the updated build-config. Thanks!
Kind Regards,

Arnaud Guidon, Rochester NY
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Post by riviere »

Hi,

Well, the change in build-config would only allow you to use libxml2 from fink if it's detected first in the paths. The library problem at run time is normal: contrarily to fink, we don't link to libraries with absolute paths because we want to make binary packages that can be installed in any directory. So you have to provide paths to the .dylibs using DYLD_LIBRARY_PATH, as you did (we generally setup DYLD_LIBRARY_PATH to a single place, and make symbolic links there to the various libraries).
I guess the segfaults are due to other missing configuration. Our programs generally need some configurarion files or other data that they must know where to find. For the same reason as above (relocatable packages), the location of this "shared" path is not hadr-coded in the programs and are setup using environment variables.
The needed variables are:
SHFJ_SHARED_PATH: path to the root tree of the "shared" project: for instance /Users/toto/shared-main
AIMS_PATH: path to aimsdata source tree: /Users/toto/aimsdata-main
if you installed anatomist:
ANATOMIST_PATH: path to anatomist source tree: /Users/toto/anatomist-main

Another crash explanation is that the programs might be built using the libxml2 from Fink and running using the lib of the system or vice versa.

I hope it will work better after this...
Denis
Guidon
Posts: 23
Joined: Fri Mar 25, 2005 9:34 pm
Location: Rochester, New York, USA
Contact:

Post by Guidon »

Hi Denis,

I realized that I blamed the wrong issue in the first place. I thought that the linking problem of the brainvisa libs was due to confusing warnings about redundant symbols found in /usr/lib/libxml2 and /sw/lib/libxml2 but I found out that those warnings were harmless.
My problem was resolved by setting the PATH to the proper configuration files as you just told me.

Now it works! Thanks a lot


(Attention ça va flipper dans tous les sens :) )
Kind Regards,

Arnaud Guidon, Rochester NY
Post Reply