mspass-team / mspass

Massive Parallel Analysis System for Seismologists
https://mspass.org
BSD 3-Clause "New" or "Revised" License
28 stars 11 forks source link

mismatch in anaconda version of boost with our cmake build #446

Open pavlis opened 1 year ago

pavlis commented 1 year ago

I was getting some classic conflict problems from library incompatibilities on my local ubuntu machine I use for mspass development. The problem was coming from a library I had installed via anaconda (matplotlib which is pretty fundamental) so I uninstalled and reinstalled the latest version of anaconda.

Problem that cause is it breaks local compiles of the cxx code base. ccmake shows me cmake is looking for boost in the libraries in the anaconda tree. It apparently did that in the configuration step through the magic it uses for finding such packages. Anyway, when I compile the cxx parts of mspass I'm getting this fatal error from the build process:

  ...
[ 75%] Linking CXX shared module io.cpython-311-x86_64-linux-gnu.so
/usr/bin/ld: ../../src/lib/libmspass.a(fileio.cc.o): relocation R_X86_64_PC32 against undefined hidden symbol `_ZTCN5boost10wrapexceptINS_12bad_any_castEEE0_NS_16exception_detail10clone_implINS3_19error_info_injectorIS1_EEEE' can not be used when making a shared object
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status

A google search quickly shows this error is linked to a library being used in the link process that was not linked with the magic linux flag -fKpic. From the error I appears to be from boost. I've seen a problem before in boost with a problem mixing up static and dynamic libraries. It looks to me like anaconda's build has that issue.

I am recording this for the record. I think the only solution is to build a local copy of boost manually and make sure the static libraries are not mixed up with or compiled with -fKpic. I remember going into this dark alley a while back so I'm pretty sure I can solve it that way. Alternatively, is there a way to set up cmake to force it to download and build boost?

wangyinz commented 1 year ago

Yes, you are exactly correct. The python library that we are linking into has to be PIC library, so any dependency needs to be compiled with PIC too. For our CMake setup, I think the only way to force it download boost library is to remove this find_package line.