Reputation: 2052
I'm cross compiling a C application and am linking against the alsa library with -lasound
My newest cross compiler said it can't find the library, so I went exploring in the compiler's library directories and found.
libasound.la
libasound.so.2
libasound.so.2.0.0
I did not find a libasound.so
, so to work around my problem i created a sym link
ln -s libasound.so.2.0.0 libasound.so
and everything appears to be okay now. I am positive this is not the right way to do this though. Am I supposed to use different linker options to link against this? And what do each of the different libasound.*
files mean?
Upvotes: 2
Views: 2173
Reputation: 98358
The most usual name of libraries in Linux is:
libasound.so.2.0.0
. The last 3 numbers is the library version (major.minor.revision).libasound.so.2
is a symbolic link to the preferred (latest) 2.* version of the library, should you have more than one installed in the system. It is assumed that all the 2.* version are backwards binary compatible.libasound.la
is a text file with a lot of information about the library to be used with libtool
. Useful if you use libtool
and the other autotools.libasound.so
is a symbolic link to the library to be used by the toolchain. This is the file looked for when you link with -lasound
.You are missing the last one, maybe because in debian based systems it is installed only with the libasound-dev
package. You can simply create it manually. It is not needed during runtime because the library has a SONAME
entry in the header:
$ objdump -x /usr/lib/libasound.so | grep SONAME
SONAME libasound.so.2
That makes the dynamic linker look for that name at runtime, no matter what compiler options you used.
I hope I made some sense of this, because it is a bit complicated...
Upvotes: 4