库 link 交叉编译 aws webrtc 库时出错
library link error when cross-compiling aws webrtc library
我正在尝试为 arm 交叉编译 aws webrtc 库,但在链接 C 可执行文件时遇到错误 test_srtp。我混合了 Readme.md 的指令和一些 Whosebug post 的命令。但我仍然被困在这里 1 周,我在 google 上找不到案例。我该如何解决?
我输入了什么命令
export CC=arm-linux-gnueabihf-gcc
export CXX=arm-linux-gnueabihf-g++
export LD=arm-linux-gnueabihf-ld
export AR=arm-linux-gnueabihf-ar
cmake .. -DBUILD_TEST=TRUE -DBUILD_STATIC_LIBS=TRUE -DBUILD_OPENSSL=TRUE -DBUILD_OPENSSL_PLATFORM=linux-generic32 -DOPENSSL_EXTRA="no-async;no-asm" -DBUILD_LIBSRTP_HOST_PLATFORM=x86_64-pc-linux-gnu -DBUILD_LIBSRTP_DESTINATION_PLATFORM=arm-linux-gnueabihf
我遇到的错误
[ 66%] Performing build step for 'project_libsrtp'
Scanning dependencies of target srtp2
[ 4%] Building C object CMakeFiles/srtp2.dir/srtp/ekt.c.o
[ 8%] Building C object CMakeFiles/srtp2.dir/srtp/srtp.c.o
[ 12%] Building C object CMakeFiles/srtp2.dir/crypto/cipher/cipher.c.o
[ 16%] Building C object CMakeFiles/srtp2.dir/crypto/cipher/null_cipher.c.o
[ 20%] Building C object CMakeFiles/srtp2.dir/crypto/cipher/aes_icm_ossl.c.o
[ 24%] Building C object CMakeFiles/srtp2.dir/crypto/cipher/aes_gcm_ossl.c.o
[ 28%] Building C object CMakeFiles/srtp2.dir/crypto/hash/auth.c.o
[ 32%] Building C object CMakeFiles/srtp2.dir/crypto/hash/null_auth.c.o
[ 36%] Building C object CMakeFiles/srtp2.dir/crypto/hash/hmac_ossl.c.o
[ 40%] Building C object CMakeFiles/srtp2.dir/crypto/kernel/alloc.c.o
[ 44%] Building C object CMakeFiles/srtp2.dir/crypto/kernel/crypto_kernel.c.o
[ 48%] Building C object CMakeFiles/srtp2.dir/crypto/kernel/err.c.o
[ 52%] Building C object CMakeFiles/srtp2.dir/crypto/kernel/key.c.o
[ 56%] Building C object CMakeFiles/srtp2.dir/crypto/math/datatypes.c.o
[ 60%] Building C object CMakeFiles/srtp2.dir/crypto/math/stat.c.o
[ 64%] Building C object CMakeFiles/srtp2.dir/crypto/replay/rdb.c.o
[ 68%] Building C object CMakeFiles/srtp2.dir/crypto/replay/rdbx.c.o
[ 72%] Building C object CMakeFiles/srtp2.dir/crypto/replay/ut_sim.c.o
[ 76%] Linking C static library libsrtp2.a
[ 76%] Built target srtp2
Scanning dependencies of target test_srtp
[ 80%] Building C object CMakeFiles/test_srtp.dir/test/test_srtp.c.o
[ 84%] Linking C executable test_srtp
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: /home/jacob/Workspace/Github/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_lock_new':
threads_pthread.c:(.text+0x3a): undefined reference to `pthread_rwlock_init'
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: /home/jacob/Workspace/Github/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_read_lock':
threads_pthread.c:(.text+0x5a): undefined reference to `pthread_rwlock_rdlock'
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: /home/jacob/Workspace/Github/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_write_lock':
threads_pthread.c:(.text+0x6a): undefined reference to `pthread_rwlock_wrlock'
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: /home/jacob/Workspace/Github/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_unlock':
threads_pthread.c:(.text+0x7a): undefined reference to `pthread_rwlock_unlock'
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: /home/jacob/Workspace/Github/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_lock_free':
threads_pthread.c:(.text+0x8e): undefined reference to `pthread_rwlock_destroy'
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: /home/jacob/Workspace/Github/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_run_once':
threads_pthread.c:(.text+0xaa): undefined reference to `pthread_once'
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: /home/jacob/Workspace/Github/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_init_local':
threads_pthread.c:(.text+0xba): undefined reference to `pthread_key_create'
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: /home/jacob/Workspace/Github/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_set_local':
threads_pthread.c:(.text+0xd4): undefined reference to `pthread_setspecific'
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: /home/jacob/Workspace/Github/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_cleanup_local':
threads_pthread.c:(.text+0xe4): undefined reference to `pthread_key_delete'
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: /home/jacob/Workspace/Github/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/lib/libcrypto.a(threads_pthread.o): in function `openssl_init_fork_handlers':
threads_pthread.c:(.text+0x12a): undefined reference to `pthread_once'
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: /home/jacob/Workspace/Github/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_get_local':
threads_pthread.c:(.text+0xca): undefined reference to `pthread_getspecific'
collect2: error: ld returned 1 exit status
CMakeFiles/test_srtp.dir/build.make:96: recipe for target 'test_srtp' failed
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/test_srtp.dir/all' failed
make[5]: *** [test_srtp] Error 1
make[4]: *** [CMakeFiles/test_srtp.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make[3]: *** [all] Error 2
CMakeFiles/project_libsrtp.dir/build.make:111: recipe for target 'build/src/project_libsrtp-stamp/project_libsrtp-build' failed
make[2]: *** [build/src/project_libsrtp-stamp/project_libsrtp-build] Error 2
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/project_libsrtp.dir/all' failed
Makefile:83: recipe for target 'all' failed
make[1]: *** [CMakeFiles/project_libsrtp.dir/all] Error 2
make: *** [all] Error 2
CMake Error at CMake/Utilities.cmake:65 (message):
CMake step for libsrtp failed: 2
Call Stack (most recent call first):
CMakeLists.txt:129 (build_dependency)
-- Configuring incomplete, errors occurred!
See also "/home/jacob/Workspace/Github/amazon-kinesis-video-streams-webrtc-sdk-c/build/CMakeFiles/CMakeOutput.log".
我只是使用 mbedtls 而不是 OpenSSL 解决了这个问题。如果有人遇到同样的问题,请尝试使用 mbedtls。
cmake .. -DBUILD_STATIC_LIBS=TRUE -DUSE_OPENSSL=FALSE -DUSE_MBEDTLS=TRUE -DBUILD_LIBSRTP_HOST_PLATFORM=x86_64-pc-linux-gnu -DBUILD_LIBSRTP_DESTINATION_PLATFORM=arm-linux-gnueabihf
我正在尝试为 arm 交叉编译 aws webrtc 库,但在链接 C 可执行文件时遇到错误 test_srtp。我混合了 Readme.md 的指令和一些 Whosebug post 的命令。但我仍然被困在这里 1 周,我在 google 上找不到案例。我该如何解决?
我输入了什么命令
export CC=arm-linux-gnueabihf-gcc
export CXX=arm-linux-gnueabihf-g++
export LD=arm-linux-gnueabihf-ld
export AR=arm-linux-gnueabihf-ar
cmake .. -DBUILD_TEST=TRUE -DBUILD_STATIC_LIBS=TRUE -DBUILD_OPENSSL=TRUE -DBUILD_OPENSSL_PLATFORM=linux-generic32 -DOPENSSL_EXTRA="no-async;no-asm" -DBUILD_LIBSRTP_HOST_PLATFORM=x86_64-pc-linux-gnu -DBUILD_LIBSRTP_DESTINATION_PLATFORM=arm-linux-gnueabihf
我遇到的错误
[ 66%] Performing build step for 'project_libsrtp'
Scanning dependencies of target srtp2
[ 4%] Building C object CMakeFiles/srtp2.dir/srtp/ekt.c.o
[ 8%] Building C object CMakeFiles/srtp2.dir/srtp/srtp.c.o
[ 12%] Building C object CMakeFiles/srtp2.dir/crypto/cipher/cipher.c.o
[ 16%] Building C object CMakeFiles/srtp2.dir/crypto/cipher/null_cipher.c.o
[ 20%] Building C object CMakeFiles/srtp2.dir/crypto/cipher/aes_icm_ossl.c.o
[ 24%] Building C object CMakeFiles/srtp2.dir/crypto/cipher/aes_gcm_ossl.c.o
[ 28%] Building C object CMakeFiles/srtp2.dir/crypto/hash/auth.c.o
[ 32%] Building C object CMakeFiles/srtp2.dir/crypto/hash/null_auth.c.o
[ 36%] Building C object CMakeFiles/srtp2.dir/crypto/hash/hmac_ossl.c.o
[ 40%] Building C object CMakeFiles/srtp2.dir/crypto/kernel/alloc.c.o
[ 44%] Building C object CMakeFiles/srtp2.dir/crypto/kernel/crypto_kernel.c.o
[ 48%] Building C object CMakeFiles/srtp2.dir/crypto/kernel/err.c.o
[ 52%] Building C object CMakeFiles/srtp2.dir/crypto/kernel/key.c.o
[ 56%] Building C object CMakeFiles/srtp2.dir/crypto/math/datatypes.c.o
[ 60%] Building C object CMakeFiles/srtp2.dir/crypto/math/stat.c.o
[ 64%] Building C object CMakeFiles/srtp2.dir/crypto/replay/rdb.c.o
[ 68%] Building C object CMakeFiles/srtp2.dir/crypto/replay/rdbx.c.o
[ 72%] Building C object CMakeFiles/srtp2.dir/crypto/replay/ut_sim.c.o
[ 76%] Linking C static library libsrtp2.a
[ 76%] Built target srtp2
Scanning dependencies of target test_srtp
[ 80%] Building C object CMakeFiles/test_srtp.dir/test/test_srtp.c.o
[ 84%] Linking C executable test_srtp
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: /home/jacob/Workspace/Github/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_lock_new':
threads_pthread.c:(.text+0x3a): undefined reference to `pthread_rwlock_init'
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: /home/jacob/Workspace/Github/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_read_lock':
threads_pthread.c:(.text+0x5a): undefined reference to `pthread_rwlock_rdlock'
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: /home/jacob/Workspace/Github/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_write_lock':
threads_pthread.c:(.text+0x6a): undefined reference to `pthread_rwlock_wrlock'
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: /home/jacob/Workspace/Github/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_unlock':
threads_pthread.c:(.text+0x7a): undefined reference to `pthread_rwlock_unlock'
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: /home/jacob/Workspace/Github/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_lock_free':
threads_pthread.c:(.text+0x8e): undefined reference to `pthread_rwlock_destroy'
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: /home/jacob/Workspace/Github/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_run_once':
threads_pthread.c:(.text+0xaa): undefined reference to `pthread_once'
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: /home/jacob/Workspace/Github/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_init_local':
threads_pthread.c:(.text+0xba): undefined reference to `pthread_key_create'
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: /home/jacob/Workspace/Github/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_set_local':
threads_pthread.c:(.text+0xd4): undefined reference to `pthread_setspecific'
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: /home/jacob/Workspace/Github/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_cleanup_local':
threads_pthread.c:(.text+0xe4): undefined reference to `pthread_key_delete'
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: /home/jacob/Workspace/Github/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/lib/libcrypto.a(threads_pthread.o): in function `openssl_init_fork_handlers':
threads_pthread.c:(.text+0x12a): undefined reference to `pthread_once'
/home/jacob/Workspace/toolchain/arm-linux-gnueabihf/bin/ld: /home/jacob/Workspace/Github/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/lib/libcrypto.a(threads_pthread.o): in function `CRYPTO_THREAD_get_local':
threads_pthread.c:(.text+0xca): undefined reference to `pthread_getspecific'
collect2: error: ld returned 1 exit status
CMakeFiles/test_srtp.dir/build.make:96: recipe for target 'test_srtp' failed
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/test_srtp.dir/all' failed
make[5]: *** [test_srtp] Error 1
make[4]: *** [CMakeFiles/test_srtp.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make[3]: *** [all] Error 2
CMakeFiles/project_libsrtp.dir/build.make:111: recipe for target 'build/src/project_libsrtp-stamp/project_libsrtp-build' failed
make[2]: *** [build/src/project_libsrtp-stamp/project_libsrtp-build] Error 2
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/project_libsrtp.dir/all' failed
Makefile:83: recipe for target 'all' failed
make[1]: *** [CMakeFiles/project_libsrtp.dir/all] Error 2
make: *** [all] Error 2
CMake Error at CMake/Utilities.cmake:65 (message):
CMake step for libsrtp failed: 2
Call Stack (most recent call first):
CMakeLists.txt:129 (build_dependency)
-- Configuring incomplete, errors occurred!
See also "/home/jacob/Workspace/Github/amazon-kinesis-video-streams-webrtc-sdk-c/build/CMakeFiles/CMakeOutput.log".
我只是使用 mbedtls 而不是 OpenSSL 解决了这个问题。如果有人遇到同样的问题,请尝试使用 mbedtls。
cmake .. -DBUILD_STATIC_LIBS=TRUE -DUSE_OPENSSL=FALSE -DUSE_MBEDTLS=TRUE -DBUILD_LIBSRTP_HOST_PLATFORM=x86_64-pc-linux-gnu -DBUILD_LIBSRTP_DESTINATION_PLATFORM=arm-linux-gnueabihf