Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DSO missing from command line (With CMake)

I am trying to convert a c++ project from Windows to Debian by compiling everything again with Cmake.

I am not really use to work on Linux but I have managed to install everything properly.

This is the error:

/usr/bin/ld: ../shared/libshared.a(BigNumber.cpp.o): undefined reference to symbol 'BN_new@@OPENSSL_1.0.2d'

//usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.2: error adding symbols: DSO missing from command line

This actually seems like a common question but I don't know what to do with Cmake. I already saw few answers like:

DSO missing from command line

How do I tell CMake to link in a static library in the source directory?

How to add linker or compile flag in cmake file?

I am a bit confused, could you help me to understand what I need to do with Cmake please?

Thank you

like image 732
Rikky Avatar asked Oct 16 '16 14:10

Rikky


2 Answers

It is hard to guess what may be going wrong without seeing the CMake file itself, but here are some possible solutions.

Based on the similar error in your first referenced answer (DSO missing from command line), it would seem you may have simply forgotten to link to the libcrypto.so.1.0.2 library (or perhaps missed the ssl library as well). In my experience, these are often used in tandem, so linking both may be what you need. Use the target_link_libraries command to link these libraries to your CMake target:

target_link_libraries(MyLib PRIVATE ssl crypto)

I've also seen cases where this error arises due to a mismatch in the OpenSSL versions. For example, OpenSSL version 1.1 may be installed on your machine, but the library or packages you are using require version 1.0.2 (as the error suggests). If this is the case, you can uninstall the current OpenSSL version (1.1) and install the older version (1.0.2):

apt-get purge libssl-dev
apt-get install libssl1.0-dev
like image 106
Kevin Avatar answered Oct 04 '22 04:10

Kevin


The error you are getting is about a missing link for a function that was called in the BigNumber.cpp file.

What's is happening is that CMakeLists.txt is most likely missing a library in:

TARGET_LINK_LIBRARIES( youApp
  library1
  library2
)

PS: the order in which you call the libraries is also important to get the linker to work properly.

like image 41
MSIS Avatar answered Oct 04 '22 04:10

MSIS