DSO missing from command line (With CMake)
Asked Answered
B

2

15

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

Belden answered 16/10, 2016 at 14:58 Comment(1)
could you solve this problem? What changes did you have make to fix this? I am also having a similar problemRoselane
S
3

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
Scammon answered 22/8, 2020 at 18:45 Comment(0)
N
1

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.

Norval answered 16/10, 2016 at 15:8 Comment(2)
Hi MSIS, thank you for your answer. so I tried to add this in my CMakeLists.txt but I think I am targeting the wrong thing. Do you think that I need to target something else? Because I did that TARGET_LINK_LIBRARIES("path/BigNumber.cpp" "/usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.2")Belden
Oops sorry I pressed Enter, just to add that if I try to target this .cpp, I have got this error (Cannot specify link libraries for target ".../BigNumber.cpp" which is not built by this project.)Belden

© 2022 - 2024 — McMap. All rights reserved.