Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding path of static system libraries in Linux

I am compiling a package that links against the OpenSSL static libraries libssl.a and libcrypto.a which are included with libssl-dev in Debian/Ubuntu. However the actual location of these files depends on the architecture and distribution at hand.

Is there some sort of method or environment variable that I can use in the Makefile to give the linker the correct path to the system directory with static libraries? Currently I am using:

-L/usr/lib/x86_64-linux-gnu/ -L/usr/lib/i686-linux-gnu/ -lssl -lcrypto

However this gives a bunch of warnings if these dirs do not exist, and might still not generally work.

like image 912
Jeroen Ooms Avatar asked Oct 16 '14 23:10

Jeroen Ooms


1 Answers

If you are sure, that your users are using aptitude as package manager, that is default for Debian/Ubuntu, than you can use apt-file to locate libraries.

$ apt-file update
$ LIBSSL_PATH=`apt-file list libssl-dev | grep libssl.a | awk '{ print $2 }'`
$ LIBCRYPTO_PATH=`apt-file list libssl-dev | grep libcrypto.a | awk '{ print $2 }'`

Next you may use them. Say on my machine:

$ echo $LIBSSL_PATH
/usr/lib/libssl.a

I known no other way and doubt if any exists.

like image 129
Konstantin Vladimirov Avatar answered Oct 31 '22 10:10

Konstantin Vladimirov