1

I am building a program in c++, it is being build on windows using visual studio, but as it will be used on linux and windows I tried to compile it on Ubuntu using g++, but the compiler keeps giving me an error. (It builds fine on windows and does not use any windows dependencies)

The command that I am using is:

g++ -o Test *.cpp -I /home/user/vcpkg/installed/x64-linux/include/ -L /home/user/vcpkg/installed/x64-linux/lib/ -ldl -lbz2 -llzma -lz -lssl -lpthread -lcrypto -lcpprest -lcryptopp

the compiling part is going good, but it gives me an error with the linking, below error is what I keep on getting:


/usr/bin/ld: /home/user/vcpkg/installed/x64-linux/lib//libcrypto.a(dso_dlfcn.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libdl.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

While looking on stack overflow I saw several people with the same issues, but all I could find as an answer was to add -ldl to the command line, which I did, but did not have any effect.

Does anyone have an idea how to solve this? Any help will be greatly appreciated.

Pimmmo
  • 57
  • 7
  • 2
    Order matters! If library A depends on library B, then A must come *before* B on the command line when linking. In short, place `-ldl` *last* (or at least after `-lcrypto`). – Some programmer dude Sep 28 '18 at 11:36
  • @Someprogrammerdude your comment looks like an answer. Or maybe there's a dup somewhere? – YSC Sep 28 '18 at 11:36
  • @YSC Yes,there's so many duplicates of this that I'm sure someone will come and close this soon. – Some programmer dude Sep 28 '18 at 11:37
  • Thanks @Someprogrammerdude that did the trick :) Sorry for the noob question, its my first time building with g++ – Pimmmo Sep 28 '18 at 18:00

0 Answers0