SuperElastix / SimpleElastix

Multi-lingual medical image registration library
http://simpleelastix.github.io
Apache License 2.0
507 stars 149 forks source link

Compilation error: cannot find -lelastix #453

Open franciscomcm opened 2 years ago

franciscomcm commented 2 years ago

Hello,

I am trying to compile SimpleElastix following the instructions given here and here (for Python 3.x). I followed the steps and managed to fix some of the errors I encountered in the process, but it still fails at 100% with a linker error:

[100%] Building CXX object Wrapping/Python/CMakeFiles/SimpleITK_PYTHON.dir/sitkPyCommand.cxx.o
[100%] Building CXX object Wrapping/Python/CMakeFiles/SimpleITK_PYTHON.dir/SimpleITKPYTHON_wrap.cxx.o
[100%] Linking CXX shared module _SimpleITK.so
/usr/bin/ld.gold: error: cannot find -lelastix
/usr/bin/ld.gold: error: cannot find -ltransformix
collect2: error: ld returned 1 exit status
make[5]: *** [Wrapping/Python/CMakeFiles/SimpleITK_PYTHON.dir/build.make:656: Wrapping/Python/_SimpleITK.so] Error 1
make[4]: *** [CMakeFiles/Makefile2:1986: Wrapping/Python/CMakeFiles/SimpleITK_PYTHON.dir/all] Error 2
make[3]: *** [Makefile:156: all] Error 2
make[2]: *** [CMakeFiles/SimpleITK.dir/build.make:88: SimpleITK-prefix/src/SimpleITK-stamp/SimpleITK-build] Error 2
make[1]: *** [CMakeFiles/Makefile2:185: CMakeFiles/SimpleITK.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

I tried on macOS Big Sur v11.6 (Apple clang version 12.0.0) and Fedora release 34 (clang version 12.0.1, gcc 11.2.1, GNU ld version 2.35.2-6.fc34).

I would appreciate any help! Thank you!

galih112 commented 2 years ago

Hi, did you end up solving this issue? I get the same error after following the Manually Building On Linux steps.

ChristosChadoulos commented 2 years ago

I was having the exact same problem but i found a solution that seems to work. I built elastix v5.0.1 manually using the -fPIC flag for the g++ compiler. Assuming the installation directory is set to /usr/local, the static libraries libelastix-5.0.a and libtransformix-5.0.a are installed in /usr/local/lib.

Before proceeding to build SimpleElastix, i created a link of these two libraries to libelastix.a and libtransformix.a respectively: cd /usr/local/lib sudo ln libelastix-5.0.a libelastix.a sudo ln libtransformix-5.0.a libtransformix.a and the built was successful.

I doubt that this is a 'good' solution but it nevertheless worked for me. Hope this helps!

galih112 commented 2 years ago

Thanks! @ChristosChadoulos I was able to build and install without errors thanks to your advice

however, there is still a problem- once I try to import SimpleITK I get this error: ImportError: /home/gali/anaconda3/envs/thesis/lib/python3.9/site-packages/SimpleITK-2.0.0rc2.dev910+ga138e-py3.9-linux-x86_64.egg/SimpleITK/_SimpleITK.cpython-39-x86_64-linux-gnu.so: undefined symbol: _ZTIN11xoutlibrary8xoutbaseE

can I ask what versions/tags/commits you've used for ITK, elastix, simpleITK and simpleelastix? maybe I'll start over with the versions that have worked for you

thanks again!

franciscomcm commented 2 years ago

Hi @galihod! Unfortunately not, I ended up getting ITKElastix to work instead. I will also give a try to Christos solution!