Alexander Dyagilev
Alexander Dyagilev

Reputation: 1325

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:

  1. If I compile A with just specifying paths to my OpenSSL headers 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
  1. If I compile A with 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.

Upvotes: 0

Views: 134

Answers (1)

Alexander Dyagilev
Alexander Dyagilev

Reputation: 1325

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

Upvotes: 0

Related Questions