'Weird dynamic linker issue under Linux
I'm not an experienced Linux developer (my primary platform is Windows).
I have a dynamically loading .so module (let's call it module A) which is statically linked with Libtorrent 1.2.15.
I compiled Libtorrent with OpenSSL 1.1.1g (which was previously built by me too).
Now, a weird issue. Two different cases:
- If I compile
Awith just specifying paths to myOpenSSLheaders and libs and NOT specifying exact library files - all is working fine! Module is compiled OK, loaded OK, works OK.
I.e. , in my Qt project this looks so:
LIBS += -Lpath_to_my_openssl/prebuilt/linux/lib
- If I compile
Awith also specifying the exact library files - it's compiled OK, loaded OK (I can parse torrents using this loaded module), but crashes when I actually trying to start a torrent. It crashes with the following error:
/home/user/Desktop/build/ui/../bin/app: symbol lookup error: /home/user/Desktop/build/ui/../bin/libdownloadsbt.so.6: undefined symbol: TLS_client_method
In my Qt project this looks so:
LIBS += -Lpath_to_my_openssl/prebuilt/linux/lib
LIBS += -lcrypto -lssl
The second line is all the difference.
What is going on?
P.S. Works fine under Windows and macOS.
Solution 1:[1]
Thanks all guys for the comments and help. The reason was the order of the libraries. Under Linux, their linking order matters.
So, this works fine:
-ltorrent-rasterbar -lcrypto -lssl
This crashes at runtime:
-lcrypto -lssl -ltorrent-rasterbar
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Alexander Dyagilev |
