使用cygwin时如何静态link libssl和libcrypto?
How to statically link libssl and libcrypto when using cygwin?
cmake_minimum_required(VERSION 3.17)
project(test)
set(CMAKE_CXX_STANDARD 17)
add_executable(test main.cpp)
target_link_libraries(test ssl crypto)
使用上面的CMakeLists.txt时,可以link动态的openssl lib
但是当添加 -static
cmake_minimum_required(VERSION 3.17)
project(test)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
add_executable(test main.cpp)
target_link_libraries(test ssl crypto)
发生错误
/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lssl
/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lcrypto
如何在使用 cygwin 时静态 link libssl 和 libcrypto?
见
https://cygwin.com/packages/x86_64/libssl-devel/libssl-devel-1.1.1n-1
包只提供共享导入库
usr/lib/libcrypto.dll.a
usr/lib/libssl.dll.a
所以你不能静态地link他们
cmake_minimum_required(VERSION 3.17)
project(test)
set(CMAKE_CXX_STANDARD 17)
add_executable(test main.cpp)
target_link_libraries(test ssl crypto)
使用上面的CMakeLists.txt时,可以link动态的openssl lib
但是当添加 -static
cmake_minimum_required(VERSION 3.17)
project(test)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
add_executable(test main.cpp)
target_link_libraries(test ssl crypto)
发生错误
/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lssl
/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lcrypto
如何在使用 cygwin 时静态 link libssl 和 libcrypto?
见
https://cygwin.com/packages/x86_64/libssl-devel/libssl-devel-1.1.1n-1
包只提供共享导入库
usr/lib/libcrypto.dll.a
usr/lib/libssl.dll.a
所以你不能静态地link他们