How do you link to a specific version of a shared library in GCC

Adam Pierce picture Adam Pierce · May 6, 2009 · Viewed 44.6k times · Source

I'm compiling some code which uses libcurl on a Debian Linux system. My dev machine is running Debian 5 but I want the binary to be usable on older Debian 4 systems too.

I find that if I specify -lcurl it will link to libcurl.so.4 but Debian 4 systems only have libcurl.so.3

Is there some way I can tell GCC to link to either libcurl.so.3 (which exists in both Debian 4 and 5) or just libcurl.so so it will use whatever version is available ?

Answer

engineer.udays picture engineer.udays · Jun 25, 2013

Instead of using "-lcurl" use "-l:libcurl.so.3" And ofcourse also use "-L _installed_path_"