Friday, December 4, 2015

Build libcurl from source ( curl: (48) An unknown option was passed in to libcurl )




After I build curl from source(On my ubuntu 12.04 machine), when I test curl like this:
curl -R -O http://www.lua.org/ftp/lua-5.3.2.tar.gz

it output an error message saying: curl: (48) An unknown option was passed in to libcurl

after a bit dive I found that this is because the newly installed curl uses an old shared_library(*.so) in an old directory.
We can use the below commands to find out what causes this error:
use curl -V to show the version of libcurl that curl uses
curl -V
curl 7.46.0 (x86_64-unknown-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
we can see that the newly installed curl 7.46.0 uses is libcurl 7.22.0(which is obvious outdated), all we need to do is to fix this:
which curl
/usr/local/bin/curl
ldd /usr/local/bin/curl
linux-vdso.so.1 => (0x00007fff655f1000)
libcurl.so.4 => /usr/lib/x86_64-linux-gnu/libcurl.so.4(0x00007f390ecad000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f390ea96000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f390e88d000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f390e4ce000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f390e2b1000)
/lib64/ld-linux-x86-64.so.2 (0x00007f390ef12000) 
as we can see from the red font line, the libcurl.so.4 that curl uses is actually located at /usr/lib/x86_64-linux-gnu/ directory, however the newly built libcurl.so.4 is located at /usr/local/lib,
so we need to copy those libs from /usr/local/lib/ to override the old libs in /usr/lib/x86_64-linux-gnu/.
do the following:
mv /usr/lib/x86_64-linux-gnu/libcurl.so.4 libcurl.so.4.bak
cp /usr/local/lib/libcurl.so.4 .
cp /usr/local/lib/libcurl.so.4.4.0 .
now we updated the new lib in /lib/x86_64-linux-gnu/, the errors should be fixed.
curl -V
curl 7.46.0 (x86_64-unknown-linux-gnu) libcurl/7.46.0 zlib/1.2.3.4


6 comments: