GCC can't find curl library

2019-09-04 07:23发布

问题:

I have a Dragino Yun Shield (it's an Arduino Yun basically, running OpenWRt Linino) and I have installed GCC on it as explained here:

http://www.sniff.org.uk/2014/05/building-gcc-for-yun-in-12-not-easy.html

The compiler seems to work fine for my needs (except for some floating point warnings) but I run into a problem. My C program requires the curl library and it can't be found by the linker:

gcc -shared -fPIC kii_cloud.c kii_custom.c kii_prv_utils.c -L jansson -I curl -I jansson -l jansson -l curl -o libkii.so
/mnt/sda1/gcc/bin/ld: cannot find -lcurl
collect2: ld returned 1 exit status
make: *** [build] Error 1

but the package libcurl is installed:

> opkg files libcurl
Package libcurl (7.29.0-1) is installed on root and has the following files:
/usr/lib/libcurl.so.4
/usr/lib/libcurl.so.4.3.0

It seems there's no libcurlX-dev package available (as in big Linux distros).

Is there any way to fix this? Is /usr/lib/libcurl.so what the linker wants?

Best regards and thanks.

回答1:

Try passing -L/usr/lib to your invocation. If that doesn't work then try adding -m32 then in another call -m64 both with the -L option.

gcc -shared -fPIC kii_cloud.c kii_custom.c kii_prv_utils.c -Ljansson -Icurl -Ijansson -ljansson -lcurl -o libkii.so -L/usr/lib



回答2:

I solved it by creating a symbolic link as follows:

cd /usr/lib
ln -s libcurl.so.4.3.0 libcurl.so

Best regards