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

Error when trying to configure a cmake build for static linking #1283

Closed
davidscholberg opened this issue Oct 16, 2024 · 9 comments · Fixed by #1290
Closed

Error when trying to configure a cmake build for static linking #1283

davidscholberg opened this issue Oct 16, 2024 · 9 comments · Fixed by #1290
Assignees
Labels
bug Something isn't working

Comments

@davidscholberg
Copy link

davidscholberg commented Oct 16, 2024

Git commit reference
a1a32d2 (v10.0.32)

Describe the bug
I'm attempting to build my bot with dpp statically linked. This is the FetchContent config for dpp that I'm using:

include(FetchContent)

# Fetch and build DPP.
set(BUILD_SHARED_LIBS OFF)
set(DPP_CORO ON)

FetchContent_Declare(
    dpp
    GIT_REPOSITORY https://github.com/brainboxdotcc/DPP.git
    GIT_TAG v10.0.32
)

FetchContent_MakeAvailable(dpp)

target_link_libraries(
    ${PROJECT_NAME}
    PRIVATE
    dpp
)

And here's the output of running the configure command for the build:

$ cmake -B build -D CMAKE_BUILD_TYPE=Debug
-- The C compiler identification is GNU 13.2.0
-- The CXX compiler identification is GNU 13.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- INFO: Using VCPKG if detected
-- Looking for prctl
-- Looking for prctl - found
-- Looking for pthread_setname_np
-- Looking for pthread_setname_np - found
-- Performing Test HAVE_SINGLE_PARAMETER_SETNAME_NP
-- Performing Test HAVE_SINGLE_PARAMETER_SETNAME_NP - Failed
-- Performing Test HAVE_TWO_PARAMETER_SETNAME_NP
-- Performing Test HAVE_TWO_PARAMETER_SETNAME_NP - Success
-- Performing Test AVX1
-- Performing Test AVX1 - Success
-- Performing Test AVX2
-- Performing Test AVX2 - Success
-- Performing Test AVX512
-- Performing Test AVX512 - Failed
-- Performing Test AVX1024
-- Performing Test AVX1024 - Failed
-- Detected x86_64 AVX type: AVX2 (FLAGS: -mavx2)
-- Checking for ability to update autogenerated files
-- Autogeneration is not available
-- Building static library.
-- Found Opus: /usr/include
-- Found Opus /usr/lib/x86_64-linux-gnu/libopus.a;/usr/lib/x86_64-linux-gnu/libm.a
-- Detected libopus. VOICE support will be enabled
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.a (found version "1.3")
-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.a (found version "3.0.13")
-- Building git version. Be aware git versions may be unstable!
-- CXX Namespace: ../include/dpp/mlspp/mls
-- CMake Export Namespace: MLSPP
-- OpenSSL Found: 3.0.13
-- OpenSSL Include: /usr/include
-- OpenSSL Libraries: /usr/lib/x86_64-linux-gnu/libssl.a;/usr/lib/x86_64-linux-gnu/libcrypto.a;dl
-- Enabled coroutine feature
-- Configuring test: coro_loop with source: ../src/coro_loop/*.cpp
-- Configuring test: davetest with source: ../src/davetest/*.cpp
-- Configuring test: soaktest with source: ../src/soaktest/*.cpp
-- Configuring test: unittest with source: ../src/unittest/*.cpp
Library install directory at /usr/local/lib
Include files install directory at /usr/local/include
-- Looking for C++ include filesystem
-- Looking for C++ include filesystem - found
-- Performing Test CXX_FILESYSTEM_NO_LINK_NEEDED
-- Performing Test CXX_FILESYSTEM_NO_LINK_NEEDED - Success
-- Using bundled nlohmann::json
-- Configuring done (12.0s)
CMake Error: install(EXPORT "dpp" ...) includes target "dpp" which requires target "mlspp" that is not in any export set.
CMake Error: install(EXPORT "dpp" ...) includes target "dpp" which requires target "mls_vectors" that is not in any export set.
CMake Error: install(EXPORT "dpp" ...) includes target "dpp" which requires target "bytes" that is not in any export set.
CMake Error: install(EXPORT "dpp" ...) includes target "dpp" which requires target "tls_syntax" that is not in any export set.
CMake Error: install(EXPORT "dpp" ...) includes target "dpp" which requires target "hpke" that is not in any export set.
-- Generating done (0.1s)
CMake Generate step failed.  Build files cannot be regenerated correctly.

To Reproduce
Steps to reproduce the behavior:

  1. Run cmake -B build -D CMAKE_BUILD_TYPE=Debug with the above cmake config to pull in dpp.

Expected behavior
Cmake configures the build without errors.

Screenshots
N/A

System Details:

  • OS: Ubuntu 24.04
  • Discord Client used for testing: N/A

Additional context
The above config works fine for a shared lib build.

@davidscholberg davidscholberg added the bug Something isn't working label Oct 16, 2024
@braindigitalis
Copy link
Contributor

wheres the rest of the cmake output? i dont see any error?

@braindigitalis braindigitalis removed their assignment Oct 16, 2024
@davidscholberg
Copy link
Author

@braindigitalis the entire output is all there. The errors are at the bottom:

-- Configuring done (12.0s)
CMake Error: install(EXPORT "dpp" ...) includes target "dpp" which requires target "mlspp" that is not in any export set.
CMake Error: install(EXPORT "dpp" ...) includes target "dpp" which requires target "mls_vectors" that is not in any export set.
CMake Error: install(EXPORT "dpp" ...) includes target "dpp" which requires target "bytes" that is not in any export set.
CMake Error: install(EXPORT "dpp" ...) includes target "dpp" which requires target "tls_syntax" that is not in any export set.
CMake Error: install(EXPORT "dpp" ...) includes target "dpp" which requires target "hpke" that is not in any export set.
-- Generating done (0.1s)
CMake Generate step failed.  Build files cannot be regenerated correctly.

@braindigitalis
Copy link
Contributor

do you have vcpkg installed on your system?

DPP is trying to enable building using vcpkg which is not working on 10.0.32 which is why it isnt released there yet.
Add the following build rule to your cmake and try again: -DDPP_NO_VCPKG=ON
let me know if this fixes it!

@davidscholberg
Copy link
Author

@braindigitalis unfortunately the same errors still occur:

$ cmake -B build -D CMAKE_BUILD_TYPE=Debug -DDPP_NO_VCPKG=ON
-- The C compiler identification is GNU 13.2.0
-- The CXX compiler identification is GNU 13.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- INFO: Explicitly disabling VCPKG as running inside the CI action.
-- Looking for prctl
-- Looking for prctl - found
-- Looking for pthread_setname_np
-- Looking for pthread_setname_np - found
-- Performing Test HAVE_SINGLE_PARAMETER_SETNAME_NP
-- Performing Test HAVE_SINGLE_PARAMETER_SETNAME_NP - Failed
-- Performing Test HAVE_TWO_PARAMETER_SETNAME_NP
-- Performing Test HAVE_TWO_PARAMETER_SETNAME_NP - Success
-- Performing Test AVX1
-- Performing Test AVX1 - Success
-- Performing Test AVX2
-- Performing Test AVX2 - Success
-- Performing Test AVX512
-- Performing Test AVX512 - Failed
-- Performing Test AVX1024
-- Performing Test AVX1024 - Failed
-- Detected x86_64 AVX type: AVX2 (FLAGS: -mavx2)
-- Checking for ability to update autogenerated files
-- Autogeneration is not available
-- Building static library.
-- Found Opus: /usr/include
-- Found Opus /usr/lib/x86_64-linux-gnu/libopus.a;/usr/lib/x86_64-linux-gnu/libm.a
-- Detected libopus. VOICE support will be enabled
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.a (found version "1.3")
-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.a (found version "3.0.13")
-- Building git version. Be aware git versions may be unstable!
-- CXX Namespace: ../include/dpp/mlspp/mls
-- CMake Export Namespace: MLSPP
-- OpenSSL Found: 3.0.13
-- OpenSSL Include: /usr/include
-- OpenSSL Libraries: /usr/lib/x86_64-linux-gnu/libssl.a;/usr/lib/x86_64-linux-gnu/libcrypto.a;dl
-- Enabled coroutine feature
-- Configuring test: coro_loop with source: ../src/coro_loop/*.cpp
-- Configuring test: davetest with source: ../src/davetest/*.cpp
-- Configuring test: soaktest with source: ../src/soaktest/*.cpp
-- Configuring test: unittest with source: ../src/unittest/*.cpp
Library install directory at /usr/local/lib
Include files install directory at /usr/local/include
-- Looking for C++ include filesystem
-- Looking for C++ include filesystem - found
-- Performing Test CXX_FILESYSTEM_NO_LINK_NEEDED
-- Performing Test CXX_FILESYSTEM_NO_LINK_NEEDED - Success
-- Using bundled nlohmann::json
-- Configuring done (27.2s)
CMake Error: install(EXPORT "dpp" ...) includes target "dpp" which requires target "mlspp" that is not in any export set.
CMake Error: install(EXPORT "dpp" ...) includes target "dpp" which requires target "mls_vectors" that is not in any export set.
CMake Error: install(EXPORT "dpp" ...) includes target "dpp" which requires target "bytes" that is not in any export set.
CMake Error: install(EXPORT "dpp" ...) includes target "dpp" which requires target "tls_syntax" that is not in any export set.
CMake Error: install(EXPORT "dpp" ...) includes target "dpp" which requires target "hpke" that is not in any export set.
-- Generating done (0.1s)
CMake Generate step failed.  Build files cannot be regenerated correctly.

I don't think I have vcpkg on here (certainly never used it).

@braindigitalis
Copy link
Contributor

i think the problem is with static linking in general. I am not sure of the fix right now, but we'll come up with something. Until then are you able to use dynamic linking as a workaround?

@davidscholberg
Copy link
Author

Yes dynamic linking works fine, appreciate you looking into it!

@davidscholberg
Copy link
Author

I think this stackoverflow post may be relevant, but I haven't looked deeply enough at the dpp cmake config to confirm it: https://stackoverflow.com/questions/40183810/why-does-cmake-export-require-static-libraries-used-to-build-a-shared-library

@braindigitalis braindigitalis linked a pull request Oct 18, 2024 that will close this issue
5 tasks
@braindigitalis
Copy link
Contributor

There is a PR #1290 which should fix this once it makes its way to master.

@braindigitalis braindigitalis self-assigned this Oct 18, 2024
@Jaskowicz1
Copy link
Contributor

Closing as #1290 has been merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants