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

后端 未结 4 1828
栀梦
栀梦 2020-11-30 01:11

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.

相关标签:
4条回答
  • 2020-11-30 01:34

    I think the correct way to do that will be to use the --filter and --auxiliary flags of the linker.

    They are not very documented, but should allow you to load symbols from different versions of the same library according to the machine you are installed on.

    0 讨论(0)
  • 2020-11-30 01:43

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

    0 讨论(0)
  • 2020-11-30 01:50

    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.

    0 讨论(0)
  • 2020-11-30 01:56

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

    0 讨论(0)
提交回复
热议问题