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
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
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.
Related
I can't seem to make my premake5.lua configuration to link against xcb.
I get undefined reference to "xcb_connect". So far I've tried (in premake5.lua):
libdirs {os.findlib("xcb")}
links {"xcb", "xcb-randr" }
Notice that os.findlib returns the same path for both xcb and xcb-randr.
I tried installing all sorts of packages, running pkg-config on both libs to see the required flags and also inspecting if the generated make file ones matched.
I don't know if it is related but I'm running Debian under wsl.
Maybe i'm missing something. Thanks for the help.
I'm in macOS Monterey 12.3.
When I try to load my CMAKE file on CLion. I got this error, it says that it can not find the MacOSX12.1.SDK. But my current version is in 12.3. I'm not sure why it goes to the 12.1 version rather than 12.3.
CMake Warning at /Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.21/Modules/Platform/Darwin-Initialize.cmake:303 (message):
Ignoring CMAKE_OSX_SYSROOT value:
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk"
because the directory does not exist.
And the warning like this:
CMake Error in Build/Debug/_deps/glew-src/CMakeLists.txt:
Imported target "OpenGL::GLU" includes non-existent path
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/OpenGL.framework"
in its INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:
* The path was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and references files it does not
provide.
In the meanwhile, when I try to compile my program, I got multiple clang errors show like this include path for libstdc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Werror,-Wstdlibcxx-not-found]
For this part, I tried the method first remove the current version of commandLineTools and do Xcode-select --install to fix it. But after I done that, these bugs were still there:(
I'm not sure what I have done to my Mac, It just suddenly become like this.
I am trying to build a project via cmake in qtcreator, but am having trouble with the external package dependencies.
There have been several packages that it could not find, but I added symlinks to the actual file locations into the directory cmake was looking in, afetr which they worked fine.
However, this one library libopencv_viz.so.3.2.0 isn't cooperationg with me. I added the symlink and visually verified that the file/link is in the correct location, but cmake is still telling me that it cannot find the file, and I have no clue how to solve this. As I stated in a prior post, I am still just learning cmake right now, so I have absolutely no clue why it would not be able to find a package that is verifiably in the correct location.
CMake Error at /usr/share/OpenCV/OpenCVModules.cmake:192 (message):
The imported target "opencv_viz" references the file
"/usr/lib/x86_64-linux-gnu/libopencv_viz.so.3.2.0"
but this file does not exist. Possible reasons include:
The file was deleted, renamed, or moved to another location.
An install or uninstall procedure did not complete successfully.
The installation package was faulty and contained
"/usr/share/OpenCV/OpenCVModules.cmake"
but not all the files it references.
Creating symlinks by hand suggests you have an incomplete installation. Clean up your manual symlinks, and figure out what's wrong with your installation.
It is normal on Linux that the .so.x.y.z with the full numeric version is the runtime library. That is, the file that is required for applications to run. The version number ensures that the application loads the same library that it was built against.
The .so symlink to .so.x.y.z is for the build chain. When the compiler (linker, really) goes to link against libopencv_viz, it will search for libopencv_viz.so, resolve the symlink to versioned file, and link that.
Many distributions (including Ubuntu) separate the runtime libraries from the development components. My guess is that you've installed the package named libopencv-viz3.2, but not the one named libopencv-viz-dev.
I'm currently fighting with a strange linker issue from ocsigenserver. It's apparently looking for ocaml-related openssl dynamic libraries. I have both done a brew install openssl (at latest version) and also an opam install openssl. But I still get the following error:
ocsigenserver -c /usr/local/etc/web/web.conf
Fatal error: cannot load shared library dllssl_threads_stubs
Reason: dlopen(dllssl_threads_stubs.so, 138): image not found
I am not sure what's going on here. If I do an openssl link I get
Warning: Refusing to link: openssl
Linking keg-only openssl means you may end up linking against the insecure,
deprecated system OpenSSL while using the headers from Homebrew's openssl.
Instead, pass the full include/library paths to your compiler e.g.:
-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib
Which implies to me that I might need to force ocsigen's build to include these flags, but I'm not sure if I'm on the right track. I feel like this must indicate that eliom or ssl must be installed incorrectly, and yet I've just opam reinstalled them.
You can add the library manually in the file your_project_name.conf.in as <extension path="where_shared_object_located" findlib-package="dllssl_threads_stubs"/>, to find the path where shared object file is situated on your machine you can do ldconfig -p | grep dllssl_threads_stubs hope it will be helpful.
I am trying to compile the Point Cloud Library from source (http://pointclouds.org/). After running cmake and make, I receive the following linking error:
Linking CXX executable ../../bin/pcl_convert_pcd_ascii_binary
../../lib/libpcl_io.so.1.7.2: undefined reference to `png_set_longjmp_fn'
As a newbie, I'm not sure what this error means, but I am assuming: the executable file plc_convert_pcd_ascii_binary which it is trying to build, needs to be linked to the library libpcl_io.so.1.7.2, but this library contains the function png_set_longjump_fun, and the definition of this function cannot be found?
So, I have tried looked at some similar questions on Stack Overflow, and it turns out that png_set_longjump_fun is contained in the libpng library, but was only introduced after libpng-1.4.x. After running dpkg -l | grep libpng*, I get the following output:
ii libpng12-0:amd64 1.2.50-1ubuntu2 amd64 PNG library - runtime
ii libpng12-dev 1.2.50-1ubuntu2 amd64 PNG library - development
So it looks like I need to upgrade from libpng12-dev to at least libpng14-dev. From the libpng website, I see that I can download the source for the latest version (but the latest version I can get through apt-get is only libpng12-dev). But I am worried that there may be some conflictions if I have one version installed via apt-get, and another version installed manually. However, uninstalling libpng12-dev may cause issues if there are packages which depend on this, but are not compatible with the newer version.
Therefore, what I would like to know, is whether I should uninstall/purge libpng12-dev, and then install the new version manually, or to simply install the new version whilst keeping the old version. And if I do the latter, how can I be sure that the PCL binary I am trying to compile, will link with this new library, rather than the old one?
Thanks :)
If you compile from source, you probably don't even need to install. Once you have compiled libpng, set the CMAKE_PREFIX_PATH when you compile PCL to point at the right place in the libpng build tree. This generally is what is done with cmake, so should work in this case. More information:
http://www.cmake.org/cmake/help/v3.0/variable/CMAKE_PREFIX_PATH.html
https://blogs.kde.org/2008/12/12/how-get-cmake-find-what-you-want-it
cmake - find_library - custom library location
How to point cmake at specific directory for library?