alibaba / xquic

XQUIC Library released by Alibaba is a cross-platform implementation of QUIC and HTTP/3 protocol.
Apache License 2.0
1.7k stars 327 forks source link

[Bug]: compile error on macos #30

Closed dourgulf closed 2 years ago

dourgulf commented 2 years ago

What happened?

execute cmake -j failed ld: unknown option: --whole-archive clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: [libxquic.dylib] Error 1 make[1]: [CMakeFiles/xquic.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs....

Steps To Reproduce

  1. MacSs12.1; cmake version 3.22.0
  2. follow readme compile with borningssl
  3. execute cmake -j failed ld: unknown option: --whole-archive clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: [libxquic.dylib] Error 1 make[1]: [CMakeFiles/xquic.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs....

Relevant log output

ld: unknown option: --whole-archive
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libxquic.dylib] Error 1
make[1]: *** [CMakeFiles/xquic.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 90%] Built target xquic-static
make: *** [all] Error 2
dourgulf commented 2 years ago

if I change CMakeLists.txt line 234 if(PLATFORM MATCHES "mac") to if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") this error will be solved.

But i don't know how to change others like where:

    if(PLATFORM STREQUAL "mac32")
        target_link_libraries(test_server xquic  -lm ${CMAKE_CURRENT_SOURCE_DIR}/../libevent32/lib/libevent.dylib)
        target_link_libraries(test_client xquic  -lm ${CMAKE_CURRENT_SOURCE_DIR}/../libevent32/lib/libevent.dylib)
        target_link_libraries(demo_server xquic  -lm ${CMAKE_CURRENT_SOURCE_DIR}/../libevent32/lib/libevent.dylib)
        target_link_libraries(demo_client xquic  -lm ${CMAKE_CURRENT_SOURCE_DIR}/../libevent32/lib/libevent.dylib)
    elseif(PLATFORM STREQUAL "mac")
        target_link_libraries(test_server xquic -lm -L/usr/local/lib -levent)
        target_link_libraries(test_client xquic -lm -L/usr/local/lib -levent)
        target_link_libraries(demo_server xquic -lm -L/usr/local/lib -levent)
        target_link_libraries(demo_client xquic -lm -L/usr/local/lib -levent)
    else()
        target_link_libraries(test_server xquic -levent -lm)
        target_link_libraries(test_client xquic -levent -lm)
        target_link_libraries(demo_server xquic -levent -lm)
        target_link_libraries(demo_client xquic -levent -lm)
    endif()
ruiqizhou commented 2 years ago

Hi, try to use the cmake variables -DPLATFORM=mac to build xquic on MacOS as mentioned in https://github.com/alibaba/xquic/blob/main/docs/Platforms.md#macos-release. #12 Problem resolved after add -DPLATFORM=mac flag.