Search code examples
cygwinlibcryptolibssl

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)

when use the CMakeLists.txt above, it can link the openssl lib dynamiclly

but when add -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)

error occured

/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

How to statically link libssl and libcrypto when using cygwin?


Solution

  • See
    https://cygwin.com/packages/x86_64/libssl-devel/libssl-devel-1.1.1n-1

    The package provides only the shared import lib

    usr/lib/libcrypto.dll.a
    usr/lib/libssl.dll.a
    

    So you can NOT statically link them