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

Compile with QUIC_BUILD_SHARED=OFF may failed by linking dl.a #3989

Open
2 of 4 tasks
st-jliu opened this issue Dec 7, 2023 · 3 comments
Open
2 of 4 tasks

Compile with QUIC_BUILD_SHARED=OFF may failed by linking dl.a #3989

st-jliu opened this issue Dec 7, 2023 · 3 comments
Labels
Milestone

Comments

@st-jliu
Copy link
Contributor

st-jliu commented Dec 7, 2023

Describe the bug

Try compile msquic as static library, it may failed by linking dl.a and file not found

Affected OS

  • Windows
  • Linux
  • macOS
  • Other (specify below)

Additional OS information

Docker image ubuntu:20.04

MsQuic version

v2.1

Steps taken to reproduce bug

Use FetchContent to introduce

set(QUIC_BUILD_SHARED   OFF)
include(FetchContent)
FetchContent_Declare(MsQuic
        URL                               "https://github.com/microsoft/msquic/archive/refs/tags/v2.1.8.tar.gz"
        URL_HASH                   "MD5=e620c59dbcfad952a6007b071cc5d5f5"
        )
FetchContent_MakeAvailable(MsQuic)

Expected behavior

Generate libmsquic.a without any error

Actual outcome

[ 34%] Generating ../../../../../../external/msquic/libs/libmsquic.a
/usr/bin/ar: dl.a: No such file or directory
""""""""""make[2]: *** [_deps/msquic-build/src/bin/CMakeFiles/msquic_lib.dir/build.make:77: ../../external/msquic/libs/libmsquic.a] Error 9

Additional details

Compile on ubuntu 20.04 locally or cross compile with Android NDK r23.1 LTS, will all failed by linking dl.a

@st-jliu
Copy link
Contributor Author

st-jliu commented Dec 7, 2023

Patch the cmake function flatten_link_dependencies() in src/bin/CMakeLists.txt, skip target 'dl' just like the 'Threads::Threads' can fix it, actually cmake generate static library do not need link with libdl.a nore libdl.so

--- msquic-2.1.8-old/src/bin/CMakeLists.txt	2023-03-16 20:47:31
+++ msquic-2.1.8-new/src/bin/CMakeLists.txt	2023-12-07 11:07:30
@@ -57,12 +57,13 @@
         if(NOT TARGET ${CURRENT_TARGET})
             string(FIND ${CURRENT_TARGET} "$<LINK_ONLY:" LINK_ONLY)
             string(FIND ${CURRENT_TARGET} "Threads::Threads" THREADS_TARGET)
+            string(FIND ${CURRENT_TARGET} "dl" DL_TARGET)
             string(FIND ${CURRENT_TARGET} "${CMAKE_STATIC_LIBRARY_SUFFIX}" SUFFIX_INDEX)
             if(${SUFFIX_INDEX} EQUAL "-1")
                 string(APPEND CURRENT_TARGET "${CMAKE_STATIC_LIBRARY_SUFFIX}")
             endif()

-            if(${LINK_ONLY} EQUAL "-1" AND ${THREADS_TARGET} EQUAL "-1")
+            if(${LINK_ONLY} EQUAL "-1" AND ${THREADS_TARGET} EQUAL "-1" AND ${DL_TARGET} EQUAL "-1")
                 # This is expected to be a generator expression that maps
                 # to a static library
                 set_property(

@nibanks
Copy link
Member

nibanks commented Dec 7, 2023

Would you be willing to propose a PR?

@nibanks nibanks added this to the Future milestone Dec 7, 2023
@st-jliu
Copy link
Contributor Author

st-jliu commented Dec 8, 2023

We will try verify on latest release v2.2.4 and main branch, if this issue still exist, we will prepare a PR

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

No branches or pull requests

2 participants