[BUG] mingw cross compile is unable to use static openSSL
First I compile static-only local OpenSSL.
Then
cmake -DENABLE_ENCRYPTION=1 -DENABLE_SHARED=0 -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ -DCMAKE_FIND_ROOT_PATH=/usr/x86_64-w64-mingw32/ -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER -DCMAKE_INSTALL_PREFIX=...
$ make
...
[ 98%] Linking CXX executable srt-file-transmit.exe
[100%] Linking CXX executable srt-live-transmit.exe
/usr/bin/x86_64-w64-mingw32-ld: a/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0xd0): undefined reference to `__imp_CertFreeCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /a/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x150): undefined reference to `__imp_CertFreeCertificateContext'
Expected behavior
Should respect pkg-config --libs --static libcrypto but doesn't seem to.
If you want to hard code it like other sections, maybe the following:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1492306..867fd25 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1051,7 +1051,7 @@ if (srt_libspec_static)
target_link_libraries(${TARGET_srt}_static PRIVATE crypt32.lib)
endif()
elseif (MINGW)
- target_link_libraries(${TARGET_srt}_static PRIVATE wsock32 ws2_32)
+ target_link_libraries(${TARGET_srt}_static PRIVATE wsock32 ws2_32 crypt32)
endif()
if (USE_GNUSTL)
target_link_libraries(${TARGET_srt}_static PRIVATE ${GNUSTL_LIBRARIES} ${GNUSTL_LDFLAGS})
Which seems to fix it in a manual way, thank you!
-DWITH_EXTRALIBS=-lcrypt32 didn't seem to work?
What is the compile error you get, for starters?
Does the SRT static library fail to compile unless you link it against crypt32.lib ? Or the applications fail to compile by this reason?
Sorry to be terse, here's more output, appears it's at link time with apps enabled:
cmake -DENABLE_ENCRYPTION=1 -DENABLE_SHARED=0 -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ -DCMAKE_FIND_ROOT_PATH=/usr/x86_64-w64-mingw32/ -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER -DCMAKE_INSTALL_PREFIX=/home/rdp/new/sandbox/win64_shared/build_files -DENABLE_APPS=1
CMake Warning:
No source or binary directory provided. Both will be assumed to be the
same as the current working directory, but note that this warning will
become a fatal error in future CMake releases.
-- The C compiler identification is GNU 10.0.0
-- The CXX compiler identification is GNU 10.0.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/x86_64-w64-mingw32-gcc - 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/x86_64-w64-mingw32-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2")
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- BUILD TYPE: Release
-- LOGGING: ENABLED
-- USE_BUSY_WAITING: OFF (default)
-- No WITH_COMPILER_PREFIX - using C++ compiler /usr/bin/x86_64-w64-mingw32-g++
-- Looking for inet_pton
-- Looking for inet_pton - found
-- Checking for module 'openssl libcrypto'
-- Found openssl libcrypto, version 3.2.0;3.2.0
-- SSL via pkg-config: -L /home/rdp/new/sandbox/win64_shared/build_files/lib -I /home/rdp/new/sandbox/win64_shared/build_files/include -l;ssl;crypto
-- ENCRYPTION: ENABLED, using: openssl libcrypto
-- SSL libraries: ssl;crypto
-- ENCRYPTION AEAD API: DISABLED
-- MAXREXMITBW API: DISABLED
-- COMPILER: GNU (/usr/bin/x86_64-w64-mingw32-g++) - GNU compat
-- NOTE: GNU 10.0.0 - assuming default C++11.
-- Looking for __atomic_fetch_add_8 in atomic
-- Looking for __atomic_fetch_add_8 in atomic - found
-- Performing Test HAVE_LIBATOMIC_COMPILES
-- Performing Test HAVE_LIBATOMIC_COMPILES - Success
-- Performing Test HAVE_LIBATOMIC_COMPILES_STATIC
-- Performing Test HAVE_LIBATOMIC_COMPILES_STATIC - Success
-- Performing Test HAVE_GCCATOMIC_INTRINSICS
-- Performing Test HAVE_GCCATOMIC_INTRINSICS - Success
-- Performing Test HAVE_CXX_ATOMIC
-- Performing Test HAVE_CXX_ATOMIC - Success
-- Performing Test HAVE_CXX_ATOMIC_STATIC
-- Performing Test HAVE_CXX_ATOMIC_STATIC - Success
-- Checking for C++ 'std::put_time()':
-- Performing Test HAVE_CXX_STD_PUT_TIME
-- Performing Test HAVE_CXX_STD_PUT_TIME - Success
-- STDCXX_SYNC: OFF
-- MONOTONIC_CLOCK: OFF
CMake Warning (dev) at CMakeLists.txt:659 (if):
Policy CMP0054 is not set: Only interpret if() arguments as variables or
keywords when unquoted. Run "cmake --help-policy CMP0054" for policy
details. Use the cmake_policy command to set the policy and suppress this
warning.
Quoted variables like "GNU" will no longer be dereferenced when the policy
is set to NEW. Since the policy is not set the OLD behavior will be used.
This warning is for project developers. Use -Wno-dev to suppress it.
-- DETECTED SYSTEM: WINDOWS; WIN32=1; PTW32_STATIC_LIB=1
-- ENABLE_BONDING: OFF
-- WINDOWS detected: adding compat sources: /home/rdp/new/sandbox/win64_shared/source_files/srt/common/win_time.cpp
-- APP: srt_virtual: using default C++ standard
-- ADDING TRANSITIVE LINK DEP to:srt_static : -lpthread
-- INSTALL DIRS: bin=bin lib=lib shlib=lib include=include
-- APPS: ENABLED, std=
-- APP: srtsupport_virtual: using default C++ standard
-- APP: srt-live-transmit: using default C++ standard
-- APP: srt-file-transmit: using default C++ standard
CMake Warning at CMakeLists.txt:1321 (message):
On MinGW, some C++11 apps are blocked due to lacking proper C++11 headers
for <thread>. FIX IF POSSIBLE.
-- DEVEL APPS (testing): DISABLED
-- Configuring done
-- Generating done
-- Build files have been written to: /home/rdp/new/sandbox/win64_shared/source_files/srt
++ make install -j 12
[ 1%] Building CXX object CMakeFiles/srtsupport_virtual.dir/apps/transmitmedia.cpp.obj
[ 7%] Building CXX object CMakeFiles/srtsupport_virtual.dir/apps/apputil.cpp.obj
[ 7%] Building CXX object CMakeFiles/srtsupport_virtual.dir/apps/statswriter.cpp.obj
[ 9%] Building CXX object CMakeFiles/srtsupport_virtual.dir/apps/logsupport.cpp.obj
[ 9%] Building CXX object CMakeFiles/srt_virtual.dir/srtcore/api.cpp.obj
[ 13%] Building CXX object CMakeFiles/srtsupport_virtual.dir/apps/socketoptions.cpp.obj
[ 13%] Building CXX object CMakeFiles/srtsupport_virtual.dir/apps/logsupport_appdefs.cpp.obj
[ 15%] Building CXX object CMakeFiles/srt_virtual.dir/srtcore/buffer_snd.cpp.obj
[ 20%] Building CXX object CMakeFiles/srtsupport_virtual.dir/apps/uriparser.cpp.obj
[ 20%] Building CXX object CMakeFiles/srt_virtual.dir/srtcore/buffer_tools.cpp.obj
[ 20%] Building CXX object CMakeFiles/srt_virtual.dir/srtcore/buffer_rcv.cpp.obj
[ 22%] Building CXX object CMakeFiles/srtsupport_virtual.dir/apps/verbose.cpp.obj
[ 24%] Building CXX object CMakeFiles/srt_virtual.dir/srtcore/cache.cpp.obj
[ 26%] Building CXX object CMakeFiles/srt_virtual.dir/srtcore/channel.cpp.obj
[ 28%] Building CXX object CMakeFiles/srt_virtual.dir/srtcore/common.cpp.obj
[ 30%] Building CXX object CMakeFiles/srt_virtual.dir/srtcore/core.cpp.obj
[ 32%] Building CXX object CMakeFiles/srt_virtual.dir/srtcore/crypto.cpp.obj
[ 33%] Building CXX object CMakeFiles/srt_virtual.dir/srtcore/epoll.cpp.obj
[ 35%] Building CXX object CMakeFiles/srt_virtual.dir/srtcore/fec.cpp.obj
[ 37%] Building CXX object CMakeFiles/srt_virtual.dir/srtcore/handshake.cpp.obj
[ 39%] Building CXX object CMakeFiles/srt_virtual.dir/srtcore/list.cpp.obj
[ 41%] Building CXX object CMakeFiles/srt_virtual.dir/srtcore/logger_default.cpp.obj
/home/rdp/new/sandbox/win64_shared/source_files/srt/srtcore/epoll.cpp:284:2: warning: #warning "Unsupported system for epoll. The epoll_add_ssock() API call won't work on this platform." [-Wcpp]
284 | #warning "Unsupported system for epoll. The epoll_add_ssock() API call won't work on this platform."
| ^~~~~~~
[ 43%] Building CXX object CMakeFiles/srt_virtual.dir/srtcore/logger_defs.cpp.obj
/home/rdp/new/sandbox/win64_shared/source_files/srt/srtcore/channel.cpp: In member function ‘void srt::CChannel::createSocket(int)’:
/home/rdp/new/sandbox/win64_shared/source_files/srt/srtcore/channel.cpp:166:10: warning: variable ‘cloexec_flag’ set but not used [-Wunused-but-set-variable]
166 | bool cloexec_flag = false;
| ^~~~~~~~~~~~
[ 43%] Built target srtsupport_virtual
[ 45%] Building CXX object CMakeFiles/srt_virtual.dir/srtcore/md5.cpp.obj
[ 47%] Building CXX object CMakeFiles/srt_virtual.dir/srtcore/packet.cpp.obj
[ 49%] Building CXX object CMakeFiles/srt_virtual.dir/srtcore/packetfilter.cpp.obj
[ 50%] Building CXX object CMakeFiles/srt_virtual.dir/srtcore/queue.cpp.obj
[ 52%] Building CXX object CMakeFiles/srt_virtual.dir/srtcore/congctl.cpp.obj
[ 54%] Building CXX object CMakeFiles/srt_virtual.dir/srtcore/socketconfig.cpp.obj
[ 56%] Building CXX object CMakeFiles/srt_virtual.dir/srtcore/srt_c_api.cpp.obj
[ 58%] Building C object CMakeFiles/srt_virtual.dir/srtcore/srt_compat.c.obj
[ 60%] Building CXX object CMakeFiles/srt_virtual.dir/srtcore/strerror_defs.cpp.obj
[ 62%] Building CXX object CMakeFiles/srt_virtual.dir/srtcore/sync.cpp.obj
[ 64%] Building CXX object CMakeFiles/srt_virtual.dir/srtcore/tsbpd_time.cpp.obj
[ 66%] Building CXX object CMakeFiles/srt_virtual.dir/srtcore/window.cpp.obj
[ 67%] Building CXX object CMakeFiles/srt_virtual.dir/srtcore/sync_posix.cpp.obj
[ 69%] Building C object CMakeFiles/srt_virtual.dir/haicrypt/cryspr.c.obj
[ 71%] Building C object CMakeFiles/srt_virtual.dir/haicrypt/cryspr-openssl.c.obj
[ 73%] Building C object CMakeFiles/srt_virtual.dir/haicrypt/hcrypt.c.obj
[ 75%] Building C object CMakeFiles/srt_virtual.dir/haicrypt/hcrypt_ctx_rx.c.obj
[ 77%] Building C object CMakeFiles/srt_virtual.dir/haicrypt/hcrypt_ctx_tx.c.obj
[ 79%] Building C object CMakeFiles/srt_virtual.dir/haicrypt/hcrypt_rx.c.obj
[ 81%] Building C object CMakeFiles/srt_virtual.dir/haicrypt/hcrypt_sa.c.obj
[ 83%] Building C object CMakeFiles/srt_virtual.dir/haicrypt/hcrypt_tx.c.obj
[ 84%] Building C object CMakeFiles/srt_virtual.dir/haicrypt/hcrypt_xpt_srt.c.obj
[ 86%] Building CXX object CMakeFiles/srt_virtual.dir/haicrypt/haicrypt_log.cpp.obj
[ 88%] Building CXX object CMakeFiles/srt_virtual.dir/common/win_time.cpp.obj
/home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/cryspr-openssl.c: In function ‘crysprOpenSSL_AES_SetKey’:
/home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/cryspr-openssl.c:51:9: warning: ‘AES_set_encrypt_key’ is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
51 | if (AES_set_encrypt_key(kstr, (int)(kstr_len * 8), aes_key)) {
| ^~
In file included from /home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/cryspr-openssl.h:24,
from /home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/cryspr-config.h:9,
from /home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/cryspr.h:39,
from /home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/hcrypt.h:48,
from /home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/cryspr-openssl.c:22:
/home/rdp/new/sandbox/win64_shared/build_files/include/openssl/aes.h:51:5: note: declared here
51 | int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
| ^~~~~~~~~~~~~~~~~~~
/home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/cryspr-openssl.c:56:9: warning: ‘AES_set_decrypt_key’ is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
56 | if (AES_set_decrypt_key(kstr, (int)(kstr_len * 8), aes_key)) {
| ^~
In file included from /home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/cryspr-openssl.h:24,
from /home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/cryspr-config.h:9,
from /home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/cryspr.h:39,
from /home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/hcrypt.h:48,
from /home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/cryspr-openssl.c:22:
/home/rdp/new/sandbox/win64_shared/build_files/include/openssl/aes.h:54:5: note: declared here
54 | int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
| ^~~~~~~~~~~~~~~~~~~
/home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/cryspr-openssl.c: In function ‘crysprOpenSSL_AES_CtrCipher’:
/home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/cryspr-openssl.c:127:27: warning: ‘AES_encrypt’ is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
127 | inlen, aes_key, iv, ctr, &blk_ofs, (block128_f) AES_encrypt);
| ^~~~~
In file included from /home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/cryspr-openssl.h:24,
from /home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/cryspr-config.h:9,
from /home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/cryspr.h:39,
from /home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/hcrypt.h:48,
from /home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/cryspr-openssl.c:22:
/home/rdp/new/sandbox/win64_shared/build_files/include/openssl/aes.h:57:6: note: declared here
57 | void AES_encrypt(const unsigned char *in, unsigned char *out,
| ^~~~~~~~~~~
/home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/cryspr-openssl.c: In function ‘crysprOpenSSL_KmWrap’:
/home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/cryspr-openssl.c:178:5: warning: ‘AES_wrap_key’ is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
178 | return(((seklen + HAICRYPT_WRAPKEY_SIGN_SZ) == (unsigned int)AES_wrap_key(kek, NULL, wrap, sek, seklen)) ? 0 : -1);
| ^~~~~~
In file included from /home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/cryspr-openssl.h:24,
from /home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/cryspr-config.h:9,
from /home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/cryspr.h:39,
from /home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/hcrypt.h:48,
from /home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/cryspr-openssl.c:22:
/home/rdp/new/sandbox/win64_shared/build_files/include/openssl/aes.h:97:5: note: declared here
97 | int AES_wrap_key(AES_KEY *key, const unsigned char *iv,
| ^~~~~~~~~~~~
/home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/cryspr-openssl.c: In function ‘crysprOpenSSL_KmUnwrap’:
/home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/cryspr-openssl.c:189:5: warning: ‘AES_unwrap_key’ is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
189 | return(((wraplen - HAICRYPT_WRAPKEY_SIGN_SZ) == (unsigned int)AES_unwrap_key(kek, NULL, sek, wrap, wraplen)) ? 0 : -1);
| ^~~~~~
In file included from /home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/cryspr-openssl.h:24,
from /home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/cryspr-config.h:9,
from /home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/cryspr.h:39,
from /home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/hcrypt.h:48,
from /home/rdp/new/sandbox/win64_shared/source_files/srt/haicrypt/cryspr-openssl.c:22:
/home/rdp/new/sandbox/win64_shared/build_files/include/openssl/aes.h:101:5: note: declared here
101 | int AES_unwrap_key(AES_KEY *key, const unsigned char *iv,
| ^~~~~~~~~~~~~~
[ 88%] Built target srt_virtual
[ 90%] Building C object CMakeFiles/srt_static.dir/cmake_object_lib_support.c.obj
[ 92%] Linking CXX static library libsrt.a
[ 92%] Built target srt_static
[ 96%] Building CXX object CMakeFiles/srt-file-transmit.dir/apps/srt-file-transmit.cpp.obj
[ 96%] Building CXX object CMakeFiles/srt-live-transmit.dir/apps/srt-live-transmit.cpp.obj
[ 98%] Linking CXX executable srt-file-transmit.exe
[100%] Linking CXX executable srt-live-transmit.exe
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0xd0): undefined reference to `__imp_CertFreeCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x150): undefined reference to `__imp_CertFreeCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x570): undefined reference to `__imp_CertGetCertificateContextProperty'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0xb6c): undefined reference to `__imp_CertGetCertificateContextProperty'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0xcde): undefined reference to `__imp_CertEnumCertificatesInStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0xd91): undefined reference to `__imp_CertFindCertificateInStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x38d5): undefined reference to `__imp_CertOpenStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x3908): undefined reference to `__imp_CertEnumCertificatesInStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x3a14): undefined reference to `__imp_CertDuplicateCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x3a7e): undefined reference to `__imp_CertCloseStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x3ab9): undefined reference to `__imp_CertFreeCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x3ef0): undefined reference to `__imp_CertOpenStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x3f35): undefined reference to `__imp_CertFreeCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x3f40): undefined reference to `__imp_CertCloseStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x3f63): undefined reference to `__imp_CertEnumCertificatesInStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x46d7): undefined reference to `__imp_CertOpenStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x4745): undefined reference to `__imp_CertFreeCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x4750): undefined reference to `__imp_CertCloseStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x4899): undefined reference to `__imp_CertFreeCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x4960): undefined reference to `__imp_CertFreeCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libdefault-lib-winstore_store.obj):winstore_store:(.text+0x64): undefined reference to `__imp_CertFreeCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libdefault-lib-winstore_store.obj):winstore_store:(.text+0x83): undefined reference to `__imp_CertCloseStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libdefault-lib-winstore_store.obj):winstore_store:(.text+0x134): undefined reference to `__imp_CertOpenSystemStoreW'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libdefault-lib-winstore_store.obj):winstore_store:(.text+0x14e): undefined reference to `__imp_CertFreeCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libdefault-lib-winstore_store.obj):winstore_store:(.text+0x382): undefined reference to `__imp_CertFindCertificateInStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libdefault-lib-winstore_store.obj):winstore_store:(.text+0x5f3): undefined reference to `__imp_CertFreeCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libdefault-lib-winstore_store.obj):winstore_store:(.text+0x68f): undefined reference to `__imp_CertFindCertificateInStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0xd0): undefined reference to `__imp_CertFreeCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x150): undefined reference to `__imp_CertFreeCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x570): undefined reference to `__imp_CertGetCertificateContextProperty'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0xb6c): undefined reference to `__imp_CertGetCertificateContextProperty'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0xcde): undefined reference to `__imp_CertEnumCertificatesInStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0xd91): undefined reference to `__imp_CertFindCertificateInStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x38d5): undefined reference to `__imp_CertOpenStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x3908): undefined reference to `__imp_CertEnumCertificatesInStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x3a14): undefined reference to `__imp_CertDuplicateCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x3a7e): undefined reference to `__imp_CertCloseStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x3ab9): undefined reference to `__imp_CertFreeCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x3ef0): undefined reference to `__imp_CertOpenStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x3f35): undefined reference to `__imp_CertFreeCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x3f40): undefined reference to `__imp_CertCloseStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x3f63): undefined reference to `__imp_CertEnumCertificatesInStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x46d7): undefined reference to `__imp_CertOpenStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x4745): undefined reference to `__imp_CertFreeCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x4750): undefined reference to `__imp_CertCloseStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x4899): undefined reference to `__imp_CertFreeCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x4960): undefined reference to `__imp_CertFreeCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libdefault-lib-winstore_store.obj):winstore_store:(.text+0x64): undefined reference to `__imp_CertFreeCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libdefault-lib-winstore_store.obj):winstore_store:(.text+0x83): undefined reference to `__imp_CertCloseStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libdefault-lib-winstore_store.obj):winstore_store:(.text+0x134): undefined reference to `__imp_CertOpenSystemStoreW'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libdefault-lib-winstore_store.obj):winstore_store:(.text+0x14e): undefined reference to `__imp_CertFreeCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libdefault-lib-winstore_store.obj):winstore_store:(.text+0x382): undefined reference to `__imp_CertFindCertificateInStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libdefault-lib-winstore_store.obj):winstore_store:(.text+0x5f3): undefined reference to `__imp_CertFreeCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_shared/build_files/lib/libcrypto.a(libdefault-lib-winstore_store.obj):winstore_store:(.text+0x68f): undefined reference to `__imp_CertFindCertificateInStore'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/srt-file-transmit.dir/build.make:117: srt-file-transmit.exe] Error 1
make[1]: *** [CMakeFiles/Makefile2:197: CMakeFiles/srt-file-transmit.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/srt-live-transmit.dir/build.make:117: srt-live-transmit.exe] Error 1
make[1]: *** [CMakeFiles/Makefile2:170: CMakeFiles/srt-live-transmit.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
Thank you!
Ok, so it indeed seems like the problem is with linking srt-live-transmit.
I'm not sure how it's on Windows, but at least on Linux the static libraries don't handle dependencies. So only at the definition of linking the executable that uses this library, all dependent libraries should be passed to the command line. I'm a bit surprised that it happens here because the utility executables are compiled by default against the static SRT library.
Would you be able to repeat the "make" command, but this time with VERBOSE=1?
Sure.
srt$ make VERBOSE=1
...
[ 94%] Linking CXX executable srt-live-transmit.exe
/usr/bin/cmake -E cmake_link_script CMakeFiles/srt-live-transmit.dir/link.txt --verbose=1
/usr/bin/cmake -E rm -f CMakeFiles/srt-live-transmit.dir/objects.a
/usr/bin/x86_64-w64-mingw32-ar qc CMakeFiles/srt-live-transmit.dir/objects.a @CMakeFiles/srt-live-transmit.dir/objects1.rsp
/usr/bin/x86_64-w64-mingw32-g++ -static -static-libstdc++ -fPIC -DENABLE_LOGGING=1 -Wall -Wextra -O3 -DNDEBUG -Wl,--whole-archive CMakeFiles/srt-live-transmit.dir/objects.a -Wl,--no-whole-archive -o srt-live-transmit.exe -Wl,--out-implib,libsrt-live-transmit.dll.a -Wl,--major-image-version,0,--minor-image-version,0 @CMakeFiles/srt-live-transmit.dir/linklibs.rsp
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_static/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0xd0): undefined reference to `__imp_CertFreeCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_static/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x150): undefined reference to `__imp_CertFreeCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_static/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x570): undefined reference to `__imp_CertGetCertificateContextProperty'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_static/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0xb6c): undefined reference to `__imp_CertGetCertificateContextProperty'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_static/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0xcde): undefined reference to `__imp_CertEnumCertificatesInStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_static/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0xd91): undefined reference to `__imp_CertFindCertificateInStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_static/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x38d5): undefined reference to `__imp_CertOpenStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_static/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x3908): undefined reference to `__imp_CertEnumCertificatesInStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_static/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x3a14): undefined reference to `__imp_CertDuplicateCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_static/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x3a7e): undefined reference to `__imp_CertCloseStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_static/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x3ab9): undefined reference to `__imp_CertFreeCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_static/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x3ef0): undefined reference to `__imp_CertOpenStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_static/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x3f35): undefined reference to `__imp_CertFreeCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_static/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x3f40): undefined reference to `__imp_CertCloseStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_static/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x3f63): undefined reference to `__imp_CertEnumCertificatesInStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_static/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x46d7): undefined reference to `__imp_CertOpenStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_static/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x4745): undefined reference to `__imp_CertFreeCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_static/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x4750): undefined reference to `__imp_CertCloseStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_static/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x4899): undefined reference to `__imp_CertFreeCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_static/build_files/lib/libcrypto.a(libcrypto-lib-e_capi.obj):e_capi.c:(.text+0x4960): undefined reference to `__imp_CertFreeCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_static/build_files/lib/libcrypto.a(libdefault-lib-winstore_store.obj):winstore_store:(.text+0x64): undefined reference to `__imp_CertFreeCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_static/build_files/lib/libcrypto.a(libdefault-lib-winstore_store.obj):winstore_store:(.text+0x83): undefined reference to `__imp_CertCloseStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_static/build_files/lib/libcrypto.a(libdefault-lib-winstore_store.obj):winstore_store:(.text+0x134): undefined reference to `__imp_CertOpenSystemStoreW'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_static/build_files/lib/libcrypto.a(libdefault-lib-winstore_store.obj):winstore_store:(.text+0x14e): undefined reference to `__imp_CertFreeCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_static/build_files/lib/libcrypto.a(libdefault-lib-winstore_store.obj):winstore_store:(.text+0x382): undefined reference to `__imp_CertFindCertificateInStore'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_static/build_files/lib/libcrypto.a(libdefault-lib-winstore_store.obj):winstore_store:(.text+0x5f3): undefined reference to `__imp_CertFreeCertificateContext'
/usr/bin/x86_64-w64-mingw32-ld: /home/rdp/new/sandbox/win64_static/build_files/lib/libcrypto.a(libdefault-lib-winstore_store.obj):winstore_store:(.text+0x68f): undefined reference to `__imp_CertFindCertificateInStore'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/srt-live-transmit.dir/build.make:117: srt-live-transmit.exe] Error 1
make[2]: Leaving directory '/home/rdp/new/sandbox/win64_static/source_files/srt'
make[1]: *** [CMakeFiles/Makefile2:170: CMakeFiles/srt-live-transmit.dir/all] Error 2
make[1]: Leaving directory '/home/rdp/new/sandbox/win64_static/source_files/srt'
make: *** [Makefile:136: all] Error 2
$ cat ./CMakeFiles/srt-live-transmit.dir/linklibs.rsp
-L/home/rdp/new/sandbox/win64_static/build_files/lib libsrt.a -lssl -lcrypto -lwsock32 -lws2_32 -lpthread -latomic -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32
(no mention of -lcrypt32). It appears the it is accomodated for for "MICROSOFT"
if (MICROSOFT)
target_link_libraries(${TARGET_srt}_shared PRIVATE ws2_32.lib)
if (OPENSSL_USE_STATIC_LIBS)
target_link_libraries(${TARGET_srt}_shared PRIVATE crypt32.lib)
else()
set_target_properties(${TARGET_srt}_shared PROPERTIES LINK_FLAGS "/DELAYLOAD:libeay32.dll")
endif()
elseif (MINGW)
target_link_libraries(${TARGET_srt}_shared PRIVATE wsock32 ws2_32)
but in my case it's MINGW and I've built openssl as a "static only" lib, though haven't set OPENSSL_USE_STATIC_LIBS (though doesn't fix it with it set either) FWIW...
$ pkg-config --libs --static libcrypto
-L/home/rdp/new/sandbox/win64_static/build_files/lib -lcrypto -lws2_32 -lgdi32 -lcrypt32
Thanks!
Does it help if you temporarily add this entry declared here for Microsoft also under MinGW condition?
Maybe a better way would be to use the openssl pkg-config libs instead of hard coding them, but the current pattern works:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1492306..a7cf4cd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1052,6 +1052,9 @@ if (srt_libspec_static)
endif()
elseif (MINGW)
target_link_libraries(${TARGET_srt}_static PRIVATE wsock32 ws2_32)
+ if (OPENSSL_USE_STATIC_LIBS)
+ target_link_libraries(${TARGET_srt}_static PRIVATE crypt32)
+ endif()
endif()
if (USE_GNUSTL)
target_link_libraries(${TARGET_srt}_static PRIVATE ${GNUSTL_LIBRARIES} ${GNUSTL_LDFLAGS})
See also https://github.com/Haivision/srt/issues/565