sakra / FindMathematica

CMake module for Mathematica.
MIT License
59 stars 14 forks source link

Linking failue when libuuid is installed in a non-default directory #4

Closed Expander closed 5 years ago

Expander commented 6 years ago

Dear Sascha Kratky,

a student reported an issue to me when building a LibraryLink library with FindMathematica.cmake. He uses the following configuration:

Distributor ID: Ubuntu
Description: Ubuntu 16.04.5 LTS
Release: 16.04
Codename: xenial
Mathematica version: 10.3

When building a LibraryLink library (Himalaya_LibraryLink.so), FindMathematica.cmake links libuuid to the shared library like so:

/usr/bin/c++ -fPIC -O3 -DNDEBUG  -shared  -o Himalaya_LibraryLink.so CMakeFiles/Himalaya_LibraryLink.dir/source/LibraryLink/Himalaya_LibraryLink.cpp.o -Wl,-rpath,/home/thomas/Promotion/Himalaya/Himalaya-master/build:/home/thomas/Dokumente/Mathematica10.3/SystemFiles/Links/MathLink/DeveloperKit/Linux-x86-64/CompilerAdditions libHimalaya.so /home/thomas/Dokumente/Mathematica10.3/SystemFiles/Links/MathLink/DeveloperKit/Linux-x86-64/CompilerAdditions/libML64i4.so -lstdc++ -lm -lpthread -lrt -ldl -luuid libDSZ.so
/usr/bin/ld: cannot find -luuid
collect2: error: ld returned 1 exit status

This linking command fails and I believe it is because on this Ubuntu version libuuid is installed in the non-standard directories

/lib/x86_64-linux-gnu/libuuid.so.1
/lib/x86_64-linux-gnu/libuuid.so.1.3.0
/lib/i386-linux-gnu/libuuid.so.1
/lib/i386-linux-gnu/libuuid.so.1.3.0

This issue can be fixed by creating a symlink in /usr/lib/:

cd /usr/lib/
sudo ln -s /lib/x86_64-linux-gnu/libuuid.so.1.3.0 libuuid.so

But I believe a better solution would be to let FindMathematica.cmake search for libuuid and add its proper path to the linking command.

With best regards, Alexander Voigt

Expander commented 6 years ago

Sorry, one comment: This issue #4 has some overlap to issue #3. In issue #3 (where Fedora was used), the problem was solved by simply installing libuuid. In issue #4, however, libuuid was installed, but in a non-standard location.

I believe the fix that you proposed in issue #3 would also fix this issue #4 reported here.

sakra commented 5 years ago

Fixed in FindMathematica 3.2.5.