I have a program I'm compiling that requires a new version of Curl. Mac default Curl is in /usr/bin and /usr/lib. I have compiled a newer version of curl and compiled using:
gcc mypgm.c -I ./curl-7.58.0/include/curl -I ./cJSON-master -L ./cJSON-master/build ./libcjson.1.7.1.dylib ./libcurl.4.dylib -o mypgm
When I run mypgm I get the error:
Incompatible library version: mypgm requires version 10.0.0 or later, but libcurl.4.dylib provides version 7.0.0
Running otool
I found that the libcurl in my build dir is correct, but it seems to be wanting to use the /usr/lib version, which can't be deleted (without disable SIP, delete, reenable, which I don't want to do in case some future version reinstalls).
So my question is two-fold.
$PATH
to change the way macOS finds libraries (I read something about LD_LIBRARY_PATH
and DYLD_LIBRARY_PATH
being ignored), andgcc
line to static link those libraries?This worked after coping the libraries into the /usr/local/lib folder.
gcc -I ./curl-7.58.0/include/curl -I ./cJSON-master /usr/local/lib/libcjson.1.7.1.dylib /usr/local/lib/libcurl.4.dylib mypgm.c -o mypgm
I think the relative path (./) for the libraries rather then absolute path is the key.