cmake vcpkg elfutil libdw missing '<dlfcn.h>'
yhyu13 opened this issue · 0 comments
yhyu13 commented
Hi,
My system:
Ubuntu 20.04, clang16, cmake3.28,
I am on latest commit 51f0700 as for now Feb 2024
I used vckpkg to install elfutil using vkpkg.json, I intended to use libdw with backwardcpp
{
"dependencies": [
"spdlog",
"mimalloc",
"magic-enum",
"boost",
"elfutils"
],
"builtin-baseline": "53bef8994c541b6561884a8395ea35715ece75db"
}
And used fetch content to install backwardcpp
FetchContent_Declare(
backward
GIT_REPOSITORY https://github.com/yhyu13/backward-cpp
GIT_TAG 51f0700452cf71c57d43c2d028277b24cde32502 # or a version tag, such as v1.6
GIT_SHALLOW 1 # optional ( --depth=1 )
GIT_PROGRESS TRUE
SYSTEM # optional, the Backward include directory will be treated as system directory
)
FetchContent_MakeAvailable(backward)
# Add Backward to your target (either Backward::Interface, Backward::Object, or Backward::Backward)
target_link_libraries(Common PUBLIC Backward::Interface)
Then in my test case TestException.cpp, I included #include <backward.hpp>
The the compile target fails with dlopen cannot find under libdw source code, bascially it is the file '<dlfcn.h>' (libld) that is missing from linker.
/usr/bin/ld: vcpkg_installed/x64-linux/debug/lib/libdw.a(debuginfod-client.o): in function `__libdwfl_debuginfod_init':
/home/hangyu5/Documents/Gitrepo-My/HLVM-Engine/Engine/Source/Dependency/vcpkg/buildtrees/elfutils/x64-linux-dbg/libdwfl/.././../src/14cf90c2be-0bcffe8e4e.clean/libdwfl/debuginfod-client.c:104: undefined reference to `dlopen'
/usr/bin/ld: /home/hangyu5/Documents/Gitrepo-My/HLVM-Engine/Engine/Source/Dependency/vcpkg/buildtrees/elfutils/x64-linux-dbg/libdwfl/.././../src/14cf90c2be-0bcffe8e4e.clean/libdwfl/debuginfod-client.c:108: undefined reference to `dlsym'
/usr/bin/ld: /home/hangyu5/Documents/Gitrepo-My/HLVM-Engine/Engine/Source/Dependency/vcpkg/buildtrees/elfutils/x64-linux-dbg/libdwfl/.././../src/14cf90c2be-0bcffe8e4e.clean/libdwfl/debuginfod-client.c:109: undefined reference to `dlsym'
/usr/bin/ld: /home/hangyu5/Documents/Gitrepo-My/HLVM-Engine/Engine/Source/Dependency/vcpkg/buildtrees/elfutils/x64-linux-dbg/libdwfl/.././../src/14cf90c2be-0bcffe8e4e.clean/libdwfl/debuginfod-client.c:111: undefined reference to `dlsym'
/usr/bin/ld: /home/hangyu5/Documents/Gitrepo-My/HLVM-Engine/Engine/Source/Dependency/vcpkg/buildtrees/elfutils/x64-linux-dbg/libdwfl/.././../src/14cf90c2be-0bcffe8e4e.clean/libdwfl/debuginfod-client.c:113: undefined reference to `dlsym'
/usr/bin/ld: /home/hangyu5/Documents/Gitrepo-My/HLVM-Engine/Engine/Source/Dependency/vcpkg/buildtrees/elfutils/x64-linux-dbg/libdwfl/.././../src/14cf90c2be-0bcffe8e4e.clean/libdwfl/debuginfod-client.c:125: undefined reference to `dlclose'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
After googling a bit, I found this solution here https://gist.github.com/kwk/3595733
which simply added
target_link_libraries(Common PUBLIC ${CMAKE_DL_LIBS})
To my program target Common that backwardcpp linked to.
Consider add this to the README?