I am trying to natively compile a file in openwrt which doesn't work if of course libraries are not installed. My package depends on ixwebsocket, which I correctly managed to install, but when I perform a command like:
gcc prova.cpp -std=c++17 -lstdc++ -lssl -lixwebsocket -lpthread -lcrypto -o web_ex
The message is:
/usr/bin/ld: cannot find -lssl
/usr/bin/ld: cannot find -lpthread
/usr/bin/ld: cannot find -lcrypto
collect2: error: ld returned 1 exit status
So I added the path in PATH and $LD_LIBRARY_PATH given the fact that these libraries exist in /usr/lib, same error.
If I generate empty dummy archive files (libssl.a,libcrypto.a,..) than the compilation continues which looks really weird to me. Also the program complains about libz which as well is installed and has the corresponding archive here: /usr/lib/libz.a, dumping a series of errors which are:
IXGzipCodec.cpp:(.text+0x1b0): undefined reference to inflateInit2_' IXGzipCodec.cpp:(.text+0x1e4): undefined reference to inflate'
IXGzipCodec.cpp:(.text+0x1fc): undefined reference to `inflateEnd'
So my questions are 2:
1 - It looks to me really hacky solution create an empty archive, why this is working?
2 - Why I get the libz.a error? My best guest is that the ixwebsocket library hasn't been built with it, but on my local machine I don't get the error and the cmake cache files are the same of local machine and crosscompilation.
It is really frustrating issue, is someone could help I would appreciate.
I don't think libssl.so and libcrypto.so exists, which are the files it will look for. Usually they are symbolic links, but I don't know if it works if you make links from the existing version of those libraries.
In general you are supposed to build openwrt packages on another system using the SDK (or using a complete build tree).
Thanks for coming back to me. They are shared libraries, unless I am missing something, they should exist. Indeed looking into openwrt in the modem:
-rw-r--r-- 1 root root 268135 Feb 27 2020 libssl.so.1.0.0
-rw-r--r-- 1 root root 1166575 Feb 27 2020 libcrypto.so.1.0.0
You are right, I should crosscompile and I managed as well via that procedure to get the package. The problem here is that I can't get ixwebsocket to connect when I run it. I need to understand if I am compiling it in a wrong way as I can't connect through PORT 443, which, after having tested with curl looks open. I 'd like to give a shot via native compilation of a basic file for debugging purpose.
Yes indeed, that is why I was linking them using -l and omitting the prefix. At the end of the day I found what the mistake was, I needed also to link with -lz when I was cross-compiling the package for openwrt therefore I didn't investigate further about native compiling. Thanks anyway for your time!