views:

958

answers:

2

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 ?

+1  A: 

You can pass the actual .so file instead of -l on the linker command line, and it ought to do what you want.

bdonlan
Ah, that almost works except that libcurl.so is just a symlink to lubcurl.so.4 on Debian and so it still links to libcurl.so.4.
Adam Pierce
I'll mark this as accepted answer although it is not exactly right for libcurl on Debian 5. What I ended up doing is getting a copy of libcurl.so.3 from a Debian 4 system and linking directly to that by specifying the .so filename as bdonlan suggested.
Adam Pierce
+1  A: 

How about creating a symlink local to your project that links to .3, then you can just use -L at compile time. I'm not sure if you'd get a name conflict though, but you could always call it libcurl-old.so just in case.

Dana the Sane