C program compile lib errors

I'm trying to compile a C program that depends libcurl-devl and libexpat-devl (https://github.com/haibbo/speedtest-cli)
I'm using the toolchain from the OpenWrt SDK (aka mipsel-openwrt-linux-gcc) and I'm struggling with the dependencies.
If I execute:

mipsel-openwrt-linux-gcc -lpthread -lcurl -lexpat -lm -o speedtest_cli

I get:

/home/vichor99/openwrt-sdk-21.02.1-ramips-mt7621_gcc-8.4.0_musl.Linux-x86_64/staging_dir/toolchain-mipsel_24kc_gcc-8.4.0_musl/bin/../lib/gcc/mipsel-openwrt-linux-musl/8.4.0/../../../../mipsel-openwrt-linux-musl/bin/ld: cannot find -lcurl
/home/vichor99/openwrt-sdk-21.02.1-ramips-mt7621_gcc-8.4.0_musl.Linux-x86_64/staging_dir/toolchain-mipsel_24kc_gcc-8.4.0_musl/bin/../lib/gcc/mipsel-openwrt-linux-musl/8.4.0/../../../../mipsel-openwrt-linux-musl/bin/ld: cannot find -lexpat
collect2: error: ld returned 1 exit status

And if I use a makefile I get:

mipsel-openwrt-linux-gcc main.c -lpthread -lcurl -lexpat -lm -o speedtest_cli
main.c:9:10: fatal error: curl/curl.h: No such file or directory
 #include <curl/curl.h>
compilation terminated.
make: *** [Makefile:2: speedtest_cli] Error 1

I know that I have to override CFLAGS and LDFLAGS to point to the staging_dir/target-mipsel_.../usr/include and …/usr/lib directories; but I lack the lib directory and I think that I have to do something with the menuconfig but I'm not sure how to do that.

Can someone help me?

I solved it by executing make package/curl/compile as stated in Using the SDK and the same for the other dependencies.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.