Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake vcpkg elfutil libdw missing '<dlfcn.h>' #331

Open
yhyu13 opened this issue Feb 4, 2024 · 0 comments
Open

cmake vcpkg elfutil libdw missing '<dlfcn.h>' #331

yhyu13 opened this issue Feb 4, 2024 · 0 comments

Comments

@yhyu13
Copy link

yhyu13 commented Feb 4, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant