0

I am using libsodium in my C++ project built on QT in Linux.

Libsodium is installed and libsodium.so is in the folder /usr/lib/x86_64-linux-gnu. I have linked in the following way:

LIBS += -L/usr/lib/x86_64-linux-gnu
LIBS_T += -lsodium

(I don't think the first line is required, but I added it anyway) I am getting the following error upon compiling:

undefined reference to symbol 'sodium_free'

/usr/lib/x86_64-linux-gnu/libsodium.so: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status

How do I fix this error?

Community
  • 1
  • 1
Blue
  • 653
  • 1
  • 11
  • 26
  • 2
    `LIBS_T` looks unusual to me. `LDFLAGS` is usually the place to add `-L/usr/lib/x86_64-linux-gnu`. `LIBS` is usually the place to add `-lsodium`. Also, if you want to sidestep Linux path problems, then consider using `-l:libsodium.a`. It will static link, and not give the glibc folks the chance to miss the runtime load of `libsodium.so` or load the wrong library at runtime. – jww Jul 24 '19 at 07:18
  • Sorry, `LIBS_T` gets appended after `LIBS`. I tried static linking as well. But I am getting the same error. – Blue Jul 24 '19 at 08:51
  • The *`DSO missing...`* is usually a separate issue. It sometimes means you are missing `-ldl`. It shows up on Red Hat, CentOS and Fedora on occasion. Please state the platform; show the full command line used to compile and link; and show the exact error produced by the tool. – jww Jul 24 '19 at 08:53
  • @jww: "DSO missing..." means that the library (`/usr/lib/x86_64-linux-gnu/libsodium.so` in the given case) is actually **linked** but in a **wrong order**. – Tsyvarev Jul 25 '19 at 08:50

0 Answers0