Ошибка связывания с кросс-компиляцией iothub sdk

Я пытаюсь кросскомпилировать azure iothub sdk, написанный на C, для шлюза ARM. Этот шлюз снабжен кросс-компилятором.

Мне нужны библиотеки и включает в себя iothub для разработки на шлюзе. Я без проблем загрузил и скомпилировал zlib, curl, openssl и libuuid для устройства ARM. В настоящее время я застрял на этапе компоновки кросс-компиляции. Для компиляции sdk используется Cmake, поэтому я предоставил файл цепочки инструментов cusom для настройки путей и каталогов в моей среде разработки.

Это конфигурация системы:

  • ОС: Linux 2.6.36
  • Архитектура: ARM9
  • Версия пакета SDK для Azure IoTHub: 03.11.2017

файл цепочки инструментов (toolchain.cmake):

INCLUDE(CMakeForceCompiler)

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_VERSION 1)

set(CMAKE_C_COMPILER /opt/crosstool/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-gcc)
set(CMAKE_CXX_COMPILER /opt/crosstool/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-g++)

set(CMAKE_C_FLAGS "${CMAKE_CC_FLAGS} -L/opt/crosstool/arm-none-linux-gnueabi/arm-none-linux-gnueabi/libc/usr/lib -ldl -lcrypto -lssl")
#set(CMAKE_C_FLAGS "--std=c99 ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -L/opt/crosstool/arm-none-linux-gnueabi/arm-none-linux-gnueabi/libc/usr/lib -ldl -lcrypto -lssl")
set(CXX_FLAG_CXX11 "--std=c++11 ${CMAKE_CXX_FLAGS}")

set(CMAKE_FIND_ROOT_PATH /opt/crosstool/arm-none-linux-gnueabi/arm-none-linux-gnueabi)

#OpenSSL path
set(OPENSSL_ROOT_DIR /opt/crosstool/arm-none-linux-gnueabi/arm-none-linux-gnueabi/libc/usr/ssl)
set(OPENSSL_CRYPTO_LIBRARY /opt/crosstool/arm-none-linux-gnueabi/arm-none-linux-gnueabi/libc/usr/lib/libcrypto.so.1.0.0)
#set(OPENSSL_CRYPTO_LIBRARY /opt/crosstool/arm-none-linux-gnueabi/arm-none-linux-gnueabi/libc/armv4t/usr/lib/libcrypt.a)
set(OPENSSL_SSL_LIBRARY /opt/crosstool/arm-none-linux-gnueabi/arm-none-linux-gnueabi/libc/usr/lib/libssl.a)
set(OPENSSL_INCLUDE_DIR /opt/crosstool/arm-none-linux-gnueabi/arm-none-linux-gnueabi/libc/usr/include)

#libcurl path
set(CURL_INCLUDE_DIR /opt/crosstool/arm-none-linux-gnueabi/arm-none-linux-gnueabi/libc/usr/include/curl)
set(CURL_LIBRARY /opt/crosstool/arm-none-linux-gnueabi/arm-none-linux-gnueabi/libc/usr/lib/libcurl.a)

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

Чтобы скомпилировать SDK, я запускаю следующие команды внутри / sdk / directory / cmake /:

cmake -DCMAKE_TOOLCHAIN_FILE=../toolchain.cmake -DCMAKE_INSTALL_PREFIX=/opt/crosstool/arm-none-linux-gnueabi/arm-none-linux-gnueabi/libc/usr/
cmake --build .

Первая команда возвращает мне этот вывод:

-- The C compiler identification is GNU 4.4.1
-- The CXX compiler identification is GNU 4.4.1
-- Check for working C compiler: /opt/crosstool/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-gcc
-- Check for working C compiler: /opt/crosstool/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /opt/crosstool/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-g++
-- Check for working CXX compiler: /opt/crosstool/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for include file stdint.h
-- Looking for include file stdint.h - found
-- Looking for include file stdbool.h
-- Looking for include file stdbool.h - found
-- target architecture: ARM
-- Found OpenSSL: /opt/crosstool/arm-none-linux-gnueabi/arm-none-linux-gnueabi/libc/usr/lib/libcrypto.so.1.0.0 (found version "1.0.2m")
-- Cross compiling not using pkg-config
-- Found CURL: /opt/crosstool/arm-none-linux-gnueabi/arm-none-linux-gnueabi/libc/usr/lib/libcurl.a
-- Found CURL: /opt/crosstool/arm-none-linux-gnueabi/arm-none-linux-gnueabi/libc/usr/lib/libcurl.a
-- target architecture: ARM
-- target architecture: ARM
-- target architecture: ARM
-- iothub architecture: ARM
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ubuntu/azure-iot-sdk-c/cmake

У меня проблемы со вторым, который получил ошибку на 20% процесса при связывании файлов, это результат:

[ 19%] Built target aziotsharedutil
Scanning dependencies of target iot_c_utility
[ 20%] Building C object c-utility/samples/iot_c_utility/CMakeFiles/iot_c_utility.dir/iot_c_utility.c.o
[ 20%] Linking C executable iot_c_utility
../../libaziotsharedutil.a(tlsio_openssl.c.o): In function log_ERR_get_error': tlsio_openssl.c:(.text+0x1198): undefined reference toERR_get_error'
tlsio_openssl.c:(.text+0x11d4): undefined reference to ERR_error_string' tlsio_openssl.c:(.text+0x1224): undefined reference toERR_get_error'
../../libaziotsharedutil.a(tlsio_openssl.c.o): In function openssl_dynamic_locks_uninstall': tlsio_openssl.c:(.text+0x1450): undefined reference toCRYPTO_set_dynlock_create_callback'
tlsio_openssl.c:(.text+0x1458): undefined reference to CRYPTO_set_dynlock_lock_callback' tlsio_openssl.c:(.text+0x1460): undefined reference toCRYPTO_set_dynlock_destroy_callback'
../../libaziotsharedutil.a(tlsio_openssl.c.o): In function openssl_dynamic_locks_install': tlsio_openssl.c:(.text+0x1484): undefined reference toCRYPTO_set_dynlock_destroy_callback'
tlsio_openssl.c:(.text+0x1494): undefined reference to CRYPTO_set_dynlock_lock_callback' tlsio_openssl.c:(.text+0x14a4): undefined reference toCRYPTO_set_dynlock_create_callback'
../../libaziotsharedutil.a(tlsio_openssl.c.o): In function openssl_static_locks_lock_unlock_cb': tlsio_openssl.c:(.text+0x14ec): undefined reference toCRYPTO_num_locks'
../../libaziotsharedutil.a(tlsio_openssl.c.o): In function openssl_static_locks_uninstall': tlsio_openssl.c:(.text+0x15f4): undefined reference toCRYPTO_set_locking_callback'
tlsio_openssl.c:(.text+0x1658): undefined reference to CRYPTO_num_locks' ../../libaziotsharedutil.a(tlsio_openssl.c.o): In functionopenssl_static_locks_install':
tlsio_openssl.c:(.text+0x1790): undefined reference to CRYPTO_num_locks' tlsio_openssl.c:(.text+0x18ec): undefined reference toCRYPTO_num_locks'
tlsio_openssl.c:(.text+0x1908): undefined reference to CRYPTO_num_locks' tlsio_openssl.c:(.text+0x1980): undefined reference toCRYPTO_set_locking_callback'
../../libaziotsharedutil.a(tlsio_openssl.c.o): In function write_outgoing_bytes': tlsio_openssl.c:(.text+0x1b60): undefined reference toBIO_ctrl_pending'
tlsio_openssl.c:(.text+0x1c18): undefined reference to BIO_read' ../../libaziotsharedutil.a(tlsio_openssl.c.o): In functionsend_handshake_bytes':
tlsio_openssl.c:(.text+0x1d38): undefined reference to ERR_clear_error' tlsio_openssl.c:(.text+0x1d48): undefined reference toSSL_do_handshake'
tlsio_openssl.c:(.text+0x1d70): undefined reference to SSL_get_error' tlsio_openssl.c:(.text+0x1db8): undefined reference toERR_get_error'
tlsio_openssl.c:(.text+0x1dc8): undefined reference to ERR_error_string' ../../libaziotsharedutil.a(tlsio_openssl.c.o): In functiondecode_ssl_received_bytes':
tlsio_openssl.c:(.text+0x21d0): undefined reference to SSL_read' ../../libaziotsharedutil.a(tlsio_openssl.c.o): In functionon_underlying_io_bytes_received':
tlsio_openssl.c:(.text+0x22e8): undefined reference to BIO_write' ../../libaziotsharedutil.a(tlsio_openssl.c.o): In functionclose_openssl_instance':
tlsio_openssl.c:(.text+0x241c): undefined reference to SSL_free' tlsio_openssl.c:(.text+0x2448): undefined reference toSSL_CTX_free'
../../libaziotsharedutil.a(tlsio_openssl.c.o): In function add_certificate_to_store': tlsio_openssl.c:(.text+0x249c): undefined reference toSSL_CTX_get_cert_store'
tlsio_openssl.c:(.text+0x24d0): undefined reference to BIO_s_mem' tlsio_openssl.c:(.text+0x2508): undefined reference toBIO_new'
tlsio_openssl.c:(.text+0x2544): undefined reference to BIO_puts' tlsio_openssl.c:(.text+0x25b4): undefined reference toX509_STORE_add_cert'
tlsio_openssl.c:(.text+0x25c8): undefined reference to X509_free' tlsio_openssl.c:(.text+0x25e4): undefined reference toX509_free'
tlsio_openssl.c:(.text+0x2600): undefined reference to PEM_read_bio_X509' tlsio_openssl.c:(.text+0x263c): undefined reference toBIO_free'
../../libaziotsharedutil.a(tlsio_openssl.c.o): In function create_openssl_instance': tlsio_openssl.c:(.text+0x26b0): undefined reference toTLSv1_2_method'
tlsio_openssl.c:(.text+0x26d0): undefined reference to TLSv1_1_method' tlsio_openssl.c:(.text+0x26e0): undefined reference toTLSv1_method'
tlsio_openssl.c:(.text+0x26f0): undefined reference to SSL_CTX_new' tlsio_openssl.c:(.text+0x2758): undefined reference toSSL_CTX_free'
tlsio_openssl.c:(.text+0x27e4): undefined reference to SSL_CTX_free' tlsio_openssl.c:(.text+0x2870): undefined reference toSSL_CTX_free'
tlsio_openssl.c:(.text+0x2904): undefined reference to SSL_CTX_set_cert_verify_callback' tlsio_openssl.c:(.text+0x2908): undefined reference toBIO_s_mem'
tlsio_openssl.c:(.text+0x2914): undefined reference to BIO_new' tlsio_openssl.c:(.text+0x2940): undefined reference toSSL_CTX_free'
tlsio_openssl.c:(.text+0x296c): undefined reference to BIO_s_mem' tlsio_openssl.c:(.text+0x2978): undefined reference toBIO_new'
tlsio_openssl.c:(.text+0x29a4): undefined reference to BIO_free' tlsio_openssl.c:(.text+0x29b4): undefined reference toSSL_CTX_free'
tlsio_openssl.c:(.text+0x29f8): undefined reference to BIO_ctrl' tlsio_openssl.c:(.text+0x2a20): undefined reference toBIO_ctrl'
tlsio_openssl.c:(.text+0x2a3c): undefined reference to BIO_free' tlsio_openssl.c:(.text+0x2a4c): undefined reference toBIO_free'
tlsio_openssl.c:(.text+0x2a5c): undefined reference to SSL_CTX_free' tlsio_openssl.c:(.text+0x2ae0): undefined reference toSSL_CTX_set_verify'
tlsio_openssl.c:(.text+0x2af0): undefined reference to SSL_CTX_set_default_verify_paths' tlsio_openssl.c:(.text+0x2b60): undefined reference toSSL_new'
tlsio_openssl.c:(.text+0x2b8c): undefined reference to BIO_free' tlsio_openssl.c:(.text+0x2b9c): undefined reference toBIO_free'
tlsio_openssl.c:(.text+0x2bac): undefined reference to SSL_CTX_free' tlsio_openssl.c:(.text+0x2bfc): undefined reference toSSL_set_bio'
tlsio_openssl.c:(.text+0x2c0c): undefined reference to SSL_set_connect_state' ../../libaziotsharedutil.a(tlsio_openssl.c.o): In functiontlsio_openssl_init':
tlsio_openssl.c:(.text+0x2c88): undefined reference to SSL_library_init' tlsio_openssl.c:(.text+0x2c8c): undefined reference toSSL_load_error_strings'
tlsio_openssl.c:(.text+0x2c90): undefined reference to ERR_load_BIO_strings' tlsio_openssl.c:(.text+0x2c94): undefined reference toOPENSSL_add_all_algorithms_noconf'
../../libaziotsharedutil.a(tlsio_openssl.c.o): In function tlsio_openssl_deinit': tlsio_openssl.c:(.text+0x2d40): undefined reference toFIPS_mode_set'
tlsio_openssl.c:(.text+0x2d48): undefined reference to CRYPTO_set_locking_callback' tlsio_openssl.c:(.text+0x2d50): undefined reference toCRYPTO_set_id_callback'
tlsio_openssl.c:(.text+0x2d54): undefined reference to ERR_free_strings' tlsio_openssl.c:(.text+0x2d58): undefined reference toEVP_cleanup'
tlsio_openssl.c:(.text+0x2d60): undefined reference to ERR_remove_thread_state' tlsio_openssl.c:(.text+0x2d64): undefined reference toSSL_COMP_free_compression_methods'
tlsio_openssl.c:(.text+0x2d68): undefined reference to CRYPTO_cleanup_all_ex_data' ../../libaziotsharedutil.a(tlsio_openssl.c.o): In functiontlsio_openssl_send':
tlsio_openssl.c:(.text+0x38e4): undefined reference to SSL_write' ../../libaziotsharedutil.a(tlsio_openssl.c.o): In functiontlsio_openssl_setoption':
tlsio_openssl.c:(.text+0x423c): undefined reference to SSL_CTX_set_cert_verify_callback' tlsio_openssl.c:(.text+0x42ac): undefined reference toSSL_CTX_set_cert_verify_callback'
../../libaziotsharedutil.a(x509_openssl.c.o): In function log_ERR_get_error': x509_openssl.c:(.text+0x80): undefined reference toERR_get_error'
x509_openssl.c:(.text+0xbc): undefined reference to ERR_error_string' x509_openssl.c:(.text+0x10c): undefined reference toERR_get_error'
../../libaziotsharedutil.a(x509_openssl.c.o): In function load_certificate_chain': x509_openssl.c:(.text+0x170): undefined reference toBIO_new_mem_buf'
x509_openssl.c:(.text+0x1b4): undefined reference to PEM_read_bio_X509_AUX' x509_openssl.c:(.text+0x1f0): undefined reference toSSL_CTX_use_certificate'
x509_openssl.c:(.text+0x250): undefined reference to sk_pop_free' x509_openssl.c:(.text+0x274): undefined reference toSSL_CTX_ctrl'
x509_openssl.c:(.text+0x288): undefined reference to X509_free' x509_openssl.c:(.text+0x2ac): undefined reference toPEM_read_bio_X509'
x509_openssl.c:(.text+0x2d0): undefined reference to ERR_peek_last_error' x509_openssl.c:(.text+0x300): undefined reference toERR_clear_error'
x509_openssl.c:(.text+0x31c): undefined reference to X509_free' x509_openssl.c:(.text+0x324): undefined reference toBIO_free'
x509_openssl.c:(.text+0x344): undefined reference to X509_free' ../../libaziotsharedutil.a(x509_openssl.c.o): In functionload_alias_key_cert':
x509_openssl.c:(.text+0x374): undefined reference to BIO_new_mem_buf' x509_openssl.c:(.text+0x3b8): undefined reference toPEM_read_bio_PrivateKey'
x509_openssl.c:(.text+0x3f4): undefined reference to SSL_CTX_use_PrivateKey' x509_openssl.c:(.text+0x470): undefined reference toEVP_PKEY_free'
x509_openssl.c:(.text+0x478): undefined reference to BIO_free' ../../libaziotsharedutil.a(x509_openssl.c.o): In functionload_private_key_RSA':
x509_openssl.c:(.text+0x4c8): undefined reference to BIO_new_mem_buf' x509_openssl.c:(.text+0x50c): undefined reference toPEM_read_bio_RSAPrivateKey'
x509_openssl.c:(.text+0x548): undefined reference to SSL_CTX_use_RSAPrivateKey' x509_openssl.c:(.text+0x580): undefined reference toRSA_free'
x509_openssl.c:(.text+0x588): undefined reference to BIO_free' ../../libaziotsharedutil.a(x509_openssl.c.o): In functionx509_openssl_add_certificates':
x509_openssl.c:(.text+0xa1c): undefined reference to SSL_CTX_get_cert_store' x509_openssl.c:(.text+0xa50): undefined reference toBIO_s_mem'
x509_openssl.c:(.text+0xa88): undefined reference to BIO_new' x509_openssl.c:(.text+0xac4): undefined reference toBIO_puts'
x509_openssl.c:(.text+0xb1c): undefined reference to X509_STORE_add_cert' x509_openssl.c:(.text+0xb2c): undefined reference toERR_peek_error'
x509_openssl.c:(.text+0xb60): undefined reference to X509_free' x509_openssl.c:(.text+0xb6c): undefined reference toX509_free'
x509_openssl.c:(.text+0xb88): undefined reference to PEM_read_bio_X509' x509_openssl.c:(.text+0xbc4): undefined reference toBIO_free'
../../libaziotsharedutil.a(crt_abstractions.c.o): In function splitFloatString': crt_abstractions.c:(.text+0x10b8): undefined reference topow'
crt_abstractions.c:(.text+0x1150): undefined reference to pow' ../../libaziotsharedutil.a(crt_abstractions.c.o): In functionstrtof_s':
crt_abstractions.c:(.text+0x127c): undefined reference to pow' ../../libaziotsharedutil.a(crt_abstractions.c.o): In functionstrtold_s':
crt_abstractions.c:(.text+0x158c): undefined reference to `pow'
collect2: ld returned 1 exit status
c-utility/samples/iot_c_utility/CMakeFiles/iot_c_utility.dir/build.make:95: set di istruzioni per l'obiettivo "c-utility/samples/iot_c_utility/iot_c_utility" non riuscito
make[2]: *** [c-utility/samples/iot_c_utility/iot_c_utility] Errore 1
CMakeFiles/Makefile2:1056: set di istruzioni per l'obiettivo "c-utility/samples/iot_c_utility/CMakeFiles/iot_c_utility.dir/all" non riuscito
make[1]: *** [c-utility/samples/iot_c_utility/CMakeFiles/iot_c_utility.dir/all] Errore 2
Makefile:140: set di istruzioni per l'obiettivo "all" non riuscito
make: *** [all] Errore 2

Я пытаюсь выяснить, какую библиотеку или директиву ссылки мне не хватает, потому что я думаю, что неправильно ссылаюсь на скомпилированную библиотеку, но я еще не смог найти решение. Есть кто-нибудь, кто уже решал подобную проблему?


person Marco    schedule 10.11.2017    source источник


Ответы (1)


Используйте VERBOSE = 1, чтобы получить вывод компоновщика.

Похоже, вам не хватает ссылки на libssl и libcrypto

person arved    schedule 10.11.2017
comment
Я подключал не тот файл библиотеки, подробный вариант сработал - person Marco; 13.11.2017