Пример Azure iot sdk c: CMakeLists.txt работает, но make (Autotools) - нет - PullRequest
0 голосов
/ 08 января 2019

У меня есть следующая проблема, и я не знаю, как ее решить.

Я использую iothub_ll_client_x509_sample (azure iot sdk c) в собственном проекте. Если я использую CMakeLists.txt для компиляции проекта, все работает нормально. Но если я использую Makefile.am (Autotools) для компиляции программы, я получаю несколько неопределенных ссылок.

CMakeLists.txt выглядит так

cmake_minimum_required(VERSION 2.8.11)

set(AZUREIOT_INC_FOLDER ".." "/usr/local/include/azureiot" "/usr/local/include/azure_c_shared_utility" "/usr/local/include/azure_prov_client")

include_directories(${AZUREIOT_INC_FOLDER})

add_executable(sample_app azureSendingMessageMain.cc)

target_link_libraries(sample_app
    iothub_client_mqtt_transport
    iothub_client_amqp_transport
    iothub_client_http_transport
    iothub_client
    umqtt
    prov_auth_client
    hsm_security_client
    uhttp
    aziotsharedutil
    parson
    uuid
    pthread
    curl
    ssl
    crypto
    m
)

Мой Makefile.am выглядит так

bin_PROGRAMS = azureSendingMessage

azureSendingMessage_SOURCES = azureSendingMessageMain.cc 

azureSendingMessage_CPPFLAGS = -isystem/usr/local/include/azureiot 

azureSendingMessage_LDADD = /usr/local/lib/libiothub_client_mqtt_transport.a \
                    /usr/local/lib/libiothub_client_amqp_transport.a \
                    /usr/local/lib/libiothub_client_http_transport.a \
                    /usr/local/lib/libiothub_client.a \
                    /usr/local/lib/libumqtt.a \
                    /usr/local/lib/libprov_auth_client.a \
                    /usr/local/lib/libhsm_security_client.a \
                    /usr/local/lib/libuhttp.a \
                    /usr/local/lib/libaziotsharedutil.a \
                    /usr/local/lib/libparson.a \
                    -luuid \
                    -lpthread \
                    -lcurl \
                    -lssl \
                    -lcrypto \
                    -lm

Таким образом, оба имеют полный порядок связывания библиотек.

Если я пытаюсь скомпилировать программу с Makefile, я получаю следующие ошибки

/bin/bash ../libtool  --tag=CXX   --mode=link g++ -Wall -Werror -Wformat-security -Wignored-qualifiers -Wlogical-op -Wmissing-include-dirs -Wpointer-arith -Wundef -Wduplicated-cond -Wshift-negative-value -Wshift-overflow=2 -Wfloat-conversion -Wsized-deallocation -Wlogical-not-parentheses -Wno-strict-aliasing -g -O2 -pipe -fno-implement-inlines  -O3   -o iotProcess iotProcess-iotProcess.o iotProcess-TMPMsgIot.o iotProcess-IotCloudComm.o iotProcess-MessageHandler.o iotProcess-jsonUtil.o /usr/local/lib/libiothub_client_mqtt_transport.a /usr/local/lib/libiothub_client_amqp_transport.a /usr/local/lib/libiothub_client_http_transport.a /usr/local/lib/libiothub_client.a /usr/local/lib/libumqtt.a /usr/local/lib/libprov_auth_client.a /usr/local/lib/libhsm_security_client.a /usr/local/lib/libuhttp.a /usr/local/lib/libaziotsharedutil.a ../common/libbpng.la ../configuration/libconfiguration.la ../common/tmpMsg/libtmpmsg.la ../common/util/libutil.la /opt/telemotive/lib/i686-linux-gnu/libtmtrace.la /opt/telemotive/lib/i686-linux-gnu/libtmutil.la /opt/telemotive/lib/i686-linux-gnu/libtmproc.la /opt/telemotive/lib/i686-linux-gnu/libtmio.la /opt/telemotive/lib/i686-linux-gnu/libtmpbus.la -lpthread -lcurl -lssl -lcrypto -lm -lxerces-c -luuid /usr/local/lib/libparson.a -lmscan_api -lmdis_api
libtool: link: g++ -Wall -Werror -Wformat-security -Wignored-qualifiers -Wlogical-op -Wmissing-include-dirs -Wpointer-arith -Wundef -Wduplicated-cond -Wshift-negative-value -Wshift-overflow=2 -Wfloat-conversion -Wsized-deallocation -Wlogical-not-parentheses -Wno-strict-aliasing -g -O2 -pipe -fno-implement-inlines -O3 -o .libs/iotProcess iotProcess-iotProcess.o iotProcess-TMPMsgIot.o iotProcess-IotCloudComm.o iotProcess-MessageHandler.o iotProcess-jsonUtil.o  /usr/local/lib/libiothub_client_mqtt_transport.a /usr/local/lib/libiothub_client_amqp_transport.a /usr/local/lib/libiothub_client_http_transport.a /usr/local/lib/libiothub_client.a /usr/local/lib/libumqtt.a /usr/local/lib/libprov_auth_client.a /usr/local/lib/libhsm_security_client.a /usr/local/lib/libuhttp.a /usr/local/lib/libaziotsharedutil.a ../common/.libs/libbpng.so ../configuration/.libs/libconfiguration.so ../common/tmpMsg/.libs/libtmpmsg.so ../common/util/.libs/libutil.so /opt/telemotive/lib/i686-linux-gnu/libtmtrace.so /opt/telemotive/lib/i686-linux-gnu/libtmutil.so /opt/telemotive/lib/i686-linux-gnu/libtmproc.so /opt/telemotive/lib/i686-linux-gnu/libtmio.so /opt/telemotive/lib/i686-linux-gnu/libtmpbus.so -lpthread /usr/lib/i386-linux-gnu/libcurl-gnutls.so -lssl -lcrypto -lm -lxerces-c -luuid /usr/local/lib/libparson.a -lmscan_api -lmdis_api -pthread
/usr/local/lib/libhsm_security_client.a(hsm_client_riot.c.o): In function `generate_root_ca_info':
hsm_client_riot.c:(.text+0xa6): undefined reference to `DERInitContext'
hsm_client_riot.c:(.text+0xc4): undefined reference to `DERInitContext'
hsm_client_riot.c:(.text+0xe6): undefined reference to `X509GetDeviceCertTBS'
hsm_client_riot.c:(.text+0x150): undefined reference to `RiotCrypt_Sign'
hsm_client_riot.c:(.text+0x1b4): undefined reference to `X509MakeRootCert'
hsm_client_riot.c:(.text+0x239): undefined reference to `DERtoPEM'
hsm_client_riot.c:(.text+0x2e5): undefined reference to `X509GetDEREcc'
hsm_client_riot.c:(.text+0x34d): undefined reference to `DERtoPEM'
/usr/local/lib/libhsm_security_client.a(hsm_client_riot.c.o): In function `produce_device_cert':
hsm_client_riot.c:(.text+0x409): undefined reference to `DERInitContext'
hsm_client_riot.c:(.text+0x426): undefined reference to `X509GetDeviceCertTBS'
hsm_client_riot.c:(.text+0x48e): undefined reference to `RiotCrypt_Sign'
hsm_client_riot.c:(.text+0x4f3): undefined reference to `X509MakeDeviceCert'
hsm_client_riot.c:(.text+0x56e): undefined reference to `DERInitContext'
hsm_client_riot.c:(.text+0x58b): undefined reference to `X509GetDERCsrTbs'
hsm_client_riot.c:(.text+0x5f3): undefined reference to `RiotCrypt_Sign'
hsm_client_riot.c:(.text+0x658): undefined reference to `X509GetDERCsr'
hsm_client_riot.c:(.text+0x6c9): undefined reference to `DERInitContext'
hsm_client_riot.c:(.text+0x6e6): undefined reference to `X509GetDeviceCertTBS'
hsm_client_riot.c:(.text+0x74e): undefined reference to `RiotCrypt_Sign'
hsm_client_riot.c:(.text+0x7b0): undefined reference to `X509MakeDeviceCert'
hsm_client_riot.c:(.text+0x832): undefined reference to `DERtoPEM'
/usr/local/lib/libhsm_security_client.a(hsm_client_riot.c.o): In function `produce_alias_key_cert':
hsm_client_riot.c:(.text+0x8c6): undefined reference to `DERtoPEM'
/usr/local/lib/libhsm_security_client.a(hsm_client_riot.c.o): In function `produce_alias_key_pair':
hsm_client_riot.c:(.text+0x976): undefined reference to `DERInitContext'
hsm_client_riot.c:(.text+0x9d9): undefined reference to `X509GetDEREcc'
hsm_client_riot.c:(.text+0xa4e): undefined reference to `DERtoPEM'
/usr/local/lib/libhsm_security_client.a(hsm_client_riot.c.o): In function `produce_device_id_public':
hsm_client_riot.c:(.text+0xb01): undefined reference to `DERInitContext'
hsm_client_riot.c:(.text+0xb25): undefined reference to `X509GetDEREccPub'
hsm_client_riot.c:(.text+0xb9a): undefined reference to `DERtoPEM'
/usr/local/lib/libhsm_security_client.a(hsm_client_riot.c.o): In function `process_riot_key_info':
hsm_client_riot.c:(.text+0xcc8): undefined reference to `RiotCrypt_Hash'
hsm_client_riot.c:(.text+0xd3f): undefined reference to `RiotCrypt_DeriveEccKey'
hsm_client_riot.c:(.text+0xdb4): undefined reference to `RiotCrypt_Hash2'
hsm_client_riot.c:(.text+0xe31): undefined reference to `RiotCrypt_DeriveEccKey'
hsm_client_riot.c:(.text+0xf84): undefined reference to `DERInitContext'
hsm_client_riot.c:(.text+0xfb1): undefined reference to `X509GetAliasCertTBS'
hsm_client_riot.c:(.text+0x101c): undefined reference to `RiotCrypt_Sign'
hsm_client_riot.c:(.text+0x1084): undefined reference to `X509MakeAliasCert'
/usr/local/lib/libhsm_security_client.a(hsm_client_riot.c.o): In function `hsm_client_x509_init':
hsm_client_riot.c:(.text+0x1295): undefined reference to `DiceSHA256'
hsm_client_riot.c:(.text+0x12b9): undefined reference to `DiceSHA256_2'
/usr/local/lib/libhsm_security_client.a(hsm_client_riot.c.o): In function `hsm_client_riot_create_leaf_cert':
hsm_client_riot.c:(.text+0x1c22): undefined reference to `DERInitContext'
hsm_client_riot.c:(.text+0x1c3f): undefined reference to `X509GetDeviceCertTBS'
hsm_client_riot.c:(.text+0x1cad): undefined reference to `RiotCrypt_Sign'
hsm_client_riot.c:(.text+0x1d15): undefined reference to `X509MakeDeviceCert'
hsm_client_riot.c:(.text+0x1de9): undefined reference to `DERtoPEM'
/usr/local/lib/libhsm_security_client.a(hsm_client_tpm.c.o): In function `GetEkTemplate':
hsm_client_tpm.c:(.text+0x1f): undefined reference to `ToTpmaObject'
/usr/local/lib/libhsm_security_client.a(hsm_client_tpm.c.o): In function `GetSrkTemplate':
hsm_client_tpm.c:(.text+0x95): undefined reference to `ToTpmaObject'
/usr/local/lib/libhsm_security_client.a(hsm_client_tpm.c.o): In function `dps_umarshal_array':
hsm_client_tpm.c:(.text+0x114): undefined reference to `UINT32_Unmarshal'
/usr/local/lib/libhsm_security_client.a(hsm_client_tpm.c.o): In function `unmarshal_array':
hsm_client_tpm.c:(.text+0x1f2): undefined reference to `UINT32_Unmarshal'
/usr/local/lib/libhsm_security_client.a(hsm_client_tpm.c.o): In function `marshal_array_values':
hsm_client_tpm.c:(.text+0x32b): undefined reference to `UINT32_Unmarshal'
hsm_client_tpm.c:(.text+0x452): undefined reference to `UINT32_Unmarshal'
hsm_client_tpm.c:(.text+0x579): undefined reference to `UINT32_Unmarshal'
hsm_client_tpm.c:(.text+0x6a2): undefined reference to `TPM2B_PUBLIC_Unmarshal'
hsm_client_tpm.c:(.text+0x742): undefined reference to `UINT16_Unmarshal'
hsm_client_tpm.c:(.text+0x7de): undefined reference to `TPM2B_PRIVATE_Unmarshal'
/usr/local/lib/libhsm_security_client.a(hsm_client_tpm.c.o): In function `create_tpm_session':
hsm_client_tpm.c:(.text+0x8a1): undefined reference to `TSS_StartAuthSession'
hsm_client_tpm.c:(.text+0x907): undefined reference to `TSS_PolicySecret'
/usr/local/lib/libhsm_security_client.a(hsm_client_tpm.c.o): In function `insert_key_in_tpm':
hsm_client_tpm.c:(.text+0xa94): undefined reference to `TPM2B_ID_OBJECT_Unmarshal'
hsm_client_tpm.c:(.text+0xaf4): undefined reference to `TPM2B_ENCRYPTED_SECRET_Unmarshal'
hsm_client_tpm.c:(.text+0xb54): undefined reference to `TPM2B_PRIVATE_Unmarshal'
hsm_client_tpm.c:(.text+0xbb4): undefined reference to `TPM2B_ENCRYPTED_SECRET_Unmarshal'
hsm_client_tpm.c:(.text+0xc13): undefined reference to `TPM2B_PUBLIC_Unmarshal'
hsm_client_tpm.c:(.text+0xc73): undefined reference to `UINT16_Unmarshal'
hsm_client_tpm.c:(.text+0xcee): undefined reference to `TPM2_ActivateCredential'
hsm_client_tpm.c:(.text+0xd7b): undefined reference to `TPM2_Import'
hsm_client_tpm.c:(.text+0xe2d): undefined reference to `ToTpmaObject'
hsm_client_tpm.c:(.text+0xecc): undefined reference to `TSS_Create'
hsm_client_tpm.c:(.text+0xf46): undefined reference to `TPM2_Load'
hsm_client_tpm.c:(.text+0xfb4): undefined reference to `TPM2_EvictControl'
hsm_client_tpm.c:(.text+0xfdc): undefined reference to `TPM2_EvictControl'
hsm_client_tpm.c:(.text+0x1036): undefined reference to `TPM2_FlushContext'
/usr/local/lib/libhsm_security_client.a(hsm_client_tpm.c.o): In function `decrypt_data':
hsm_client_tpm.c:(.text+0x1131): undefined reference to `TSS_GetTpmProperty'
hsm_client_tpm.c:(.text+0x11f8): undefined reference to `TPM2B_ID_OBJECT_Unmarshal'
hsm_client_tpm.c:(.text+0x1258): undefined reference to `TPM2B_ENCRYPTED_SECRET_Unmarshal'
hsm_client_tpm.c:(.text+0x12b8): undefined reference to `TPM2B_PRIVATE_Unmarshal'
hsm_client_tpm.c:(.text+0x1318): undefined reference to `TPM2B_ENCRYPTED_SECRET_Unmarshal'
hsm_client_tpm.c:(.text+0x1377): undefined reference to `TPM2B_PUBLIC_Unmarshal'
hsm_client_tpm.c:(.text+0x13d7): undefined reference to `UINT16_Unmarshal'
hsm_client_tpm.c:(.text+0x14fa): undefined reference to `TPM2_ActivateCredential'
/usr/local/lib/libhsm_security_client.a(hsm_client_tpm.c.o): In function `initialize_tpm_device':
hsm_client_tpm.c:(.text+0x15dc): undefined reference to `TSS_CreatePwAuthSession'
hsm_client_tpm.c:(.text+0x1632): undefined reference to `Initialize_TPM_Codec'
hsm_client_tpm.c:(.text+0x16a9): undefined reference to `TSS_CreatePersistentKey'
hsm_client_tpm.c:(.text+0x1720): undefined reference to `TSS_CreatePersistentKey'
/usr/local/lib/libhsm_security_client.a(hsm_client_tpm.c.o): In function `hsm_client_tpm_destroy':
hsm_client_tpm.c:(.text+0x1885): undefined reference to `Deinit_TPM_Codec'
/usr/local/lib/libhsm_security_client.a(hsm_client_tpm.c.o): In function `hsm_client_tpm_get_endorsement_key':
hsm_client_tpm.c:(.text+0x1a8f): undefined reference to `TPM2B_PUBLIC_Marshal'
/usr/local/lib/libhsm_security_client.a(hsm_client_tpm.c.o): In function `hsm_client_tpm_get_storage_key':
hsm_client_tpm.c:(.text+0x1c63): undefined reference to `TPM2B_PUBLIC_Marshal'
/usr/local/lib/libhsm_security_client.a(hsm_client_tpm.c.o): In function `hsm_client_tpm_sign_data':
hsm_client_tpm.c:(.text+0x1e01): undefined reference to `SignData'
collect2: error: ld returned 1 exit status
Makefile:570: recipe for target 'iotProcess' failed
make: *** [iotProcess] Error 1

Я действительно понятия не имею, почему программа компилируется не с make (Autotools), а с CMakeLists.txt.

Проблема в том, что необходимо использовать make и autotools, поэтому использовать CMakeLists.txt нельзя: (

Надеюсь, кто-нибудь может помочь мне выяснить, что произошло с make (autotools) и Makefile.am

EDIT:

Хорошо, я долго играл и решил проблему, но не нашел решения.

Как я уже сказал, я использую azure iot sdk для c. Если я пытаюсь использовать MQTT_Protocol, я получаю неопределенные ошибки ссылок.

Линии

IOTHUB_DEVICE_CLIENT_LL_HANDLE device_ll_handle;
device_ll_handle = IoTHubClientCore_LL_CreateFromConnectionString(connectionString, MQTT_Protocol);

выдает ошибку. Я переупорядочиваю библиотеки во всех существующих комбинациях, но все равно получаю неопределенные ссылки ....

Кто-нибудь может мне помочь? Я скучаю по некоторым библиотекам, чтобы использовать MQTT_Protocol? Я до сих пор включаю libiothub_client_mqtt_transport.a, libuamqp.a и libumqtt.a

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...