[英]Eclipse C/C++ : Cross compile Linker error for external libraries: Ubuntu VM amd64 to Ubuntu armhf ( Raspberry Pi)
設定:
主機:-amd64 VM,用於托管安裝了Eclipse Mars x64的Ubuntu Mate 15.10。 還安裝了Linaro x64工具鏈
目標:-armhf Ubuntu Mate 15.10 Raspberry Pi
問題
我試圖交叉編譯我在git上找到的現有代碼,但是由於鏈接器錯誤,我無法這樣做。 該項目有一個已編譯的lib mqtt3as.so,它查找libcrypt和libssl。 鏈接器未找到這些鏈接。 我應該提到我嘗試了以下步驟。
-Git代碼在Raspberry Pi上構建良好
-主機到目標的交叉編譯器可以與Hello_world代碼一起正常工作。 部署和調試工作
-NFS將Raspi的/ lib和/ usr / lib掛載到toolchainx64 / lib文件夾
但沒有任何變化。 我了解此問題與鏈接器找不到庫有關。 我試圖遵循我用Google搜索的所有可能的建議。 以下是主機上eclipse的日志。 如果需要,我可以分享詳細的日志。
從字面上看,現在的想法已經用完了。 我有unix的經驗..但是那是幾年前的事,而且還很新。 如果需要,我仍然可以學習和探索。
日志記錄
18:18:50 **** Build of configuration Default for project prj_c ****
make all
Building file: ../cJSON.c
Invoking: Cross GCC Compiler
arm-linux-gnueabihf-gcc -I"/home/k/dev/workspace/iot/iot-raspberrypi/samples/c" -O2 -g -Wall -c -fmessage-length=0 -MMD -MP -MF"cJSON.d" -MT"cJSON.o" -o "cJSON.o" "../cJSON.c"
Finished building: ../cJSON.c
Building file: ../cpustat.c
Invoking: Cross GCC Compiler
arm-linux-gnueabihf-gcc -I"/home/k/dev/workspace/iot/iot-raspberrypi/samples/c" -O2 -g -Wall -c -fmessage-length=0 -MMD -MP -MF"cpustat.d" -MT"cpustat.o" -o "cpustat.o" "../cpustat.c"
../cpustat.c: In function ‘GetCPULoad’:
../cpustat.c:68:10: warning: implicit declaration of function ‘sleep’ [-Wimplicit-function-declaration]
sleep(1);
^
../cpustat.c:63:11: warning: unused variable ‘dump’ [-Wunused-variable]
char dump[50];
^
Finished building: ../cpustat.c
Building file: ../iotmain.c
Invoking: Cross GCC Compiler
arm-linux-gnueabihf-gcc -I"/home/k/dev/workspace/iot/iot-raspberrypi/samples/c" -O2 -g -Wall -c -fmessage-length=0 -MMD -MP -MF"iotmain.d" -MT"iotmain.o" -o "iotmain.o" "../iotmain.c"
../iotmain.c: In function ‘main’:
../iotmain.c:75:6: warning: unused variable ‘lckStatus’ [-Wunused-variable]
int lckStatus;
^
../iotmain.c: In function ‘trim’:
../iotmain.c:266:2: warning: implicit declaration of function ‘isspace’ [-Wimplicit-function-declaration]
while (isspace(*(++frontp)))
^
../iotmain.c: In function ‘get_config’:
../iotmain.c:291:17: warning: unused variable ‘str2’ [-Wunused-variable]
char str1[10], str2[10];
^
../iotmain.c:291:7: warning: unused variable ‘str1’ [-Wunused-variable]
char str1[10], str2[10];
^
Finished building: ../iotmain.c
Building file: ../jsonReader.c
Invoking: Cross GCC Compiler
arm-linux-gnueabihf-gcc -I"/home/k/dev/workspace/iot/iot-raspberrypi/samples/c" -O2 -g -Wall -c -fmessage-length=0 -MMD -MP -MF"jsonReader.d" -MT"jsonReader.o" -o "jsonReader.o" "../jsonReader.c"
Finished building: ../jsonReader.c
Building file: ../jsonator.c
Invoking: Cross GCC Compiler
arm-linux-gnueabihf-gcc -I"/home/k/dev/workspace/iot/iot-raspberrypi/samples/c" -O2 -g -Wall -c -fmessage-length=0 -MMD -MP -MF"jsonator.d" -MT"jsonator.o" -o "jsonator.o" "../jsonator.c"
Finished building: ../jsonator.c
Building file: ../mac.c
Invoking: Cross GCC Compiler
arm-linux-gnueabihf-gcc -I"/home/k/dev/workspace/iot/iot-raspberrypi/samples/c" -O2 -g -Wall -c -fmessage-length=0 -MMD -MP -MF"mac.d" -MT"mac.o" -o "mac.o" "../mac.c"
Finished building: ../mac.c
Building file: ../mqttPublisher.c
Invoking: Cross GCC Compiler
arm-linux-gnueabihf-gcc -I"/home/k/dev/workspace/iot/iot-raspberrypi/samples/c" -O2 -g -Wall -c -fmessage-length=0 -MMD -MP -MF"mqttPublisher.d" -MT"mqttPublisher.o" -o "mqttPublisher.o" "../mqttPublisher.c"
../mqttPublisher.c: In function ‘subscribeMessage’:
../mqttPublisher.c:117:6: warning: unused variable ‘i’ [-Wunused-variable]
int i;
^
../mqttPublisher.c:126:10: warning: ‘command’ may be used uninitialized in this function [-Wmaybe-uninitialized]
sprintf(command,"sudo /sbin/shutdown -r %d", time_delay);
^
Finished building: ../mqttPublisher.c
Building target: prj_c
Invoking: Cross G++ Linker
arm-linux-gnueabihf-g++ -L"/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib" -o "prj_c" ./cJSON.o ./cpustat.o ./iotmain.o ./jsonReader.o ./jsonator.o ./mac.o ./mqttPublisher.o -lpaho-mqtt3as
/home/k/dev/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: warning: libcrypto.so.1.0.0, needed by /home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so, not found (try using -rpath or -rpath-link)
/home/k/dev/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: warning: libssl.so.1.0.0, needed by /home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so, not found (try using -rpath or -rpath-link)
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_get_error@OPENSSL_1.0.0'
makefile:44: recipe for target 'prj_c' failed
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_CTX_load_verify_locations@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_alert_desc_string_long@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_CTX_set_msg_callback@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_get1_session@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_write@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `CRYPTO_THREADID_set_numeric@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `ERR_get_error@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_alert_type_string_long@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_CTX_set_default_passwd_cb@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_CIPHER_get_name@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_load_error_strings@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_CTX_set_default_passwd_cb_userdata@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_new@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `CRYPTO_set_locking_callback@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `OPENSSL_add_all_algorithms_noconf@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_CTX_use_PrivateKey_file@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_library_init@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_get_current_cipher@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_CTX_set_cipher_list@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_CTX_set_default_verify_paths@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_shutdown@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_connect@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_get_cipher_list@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSLv23_client_method@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_CTX_use_certificate_chain_file@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `ERR_print_errors_fp@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_CTX_set_info_callback@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_set_session@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_CTX_new@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `CRYPTO_THREADID_set_callback@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `CRYPTO_num_locks@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_free@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_read@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSLeay_version@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `ERR_load_crypto_strings@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_get_verify_result@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_CTX_free@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_CTX_ctrl@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_pending@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_CTX_set_verify@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_state_string_long@OPENSSL_1.0.0'
/home/k/dev/workspace/iot/iot-raspberrypi/samples/c/lib/libpaho-mqtt3as.so: undefined reference to `SSL_set_fd@OPENSSL_1.0.0'
collect2: error: ld returned 1 exit status
make: *** [prj_c] Error 1
18:18:52 Build Finished (took 1s.675ms)
您在構建系統上缺少2個庫: libcrypto.so.1.0.0
和libssl.so.1.0.0
。
開發人員在其存儲庫中添加了一個額外的部分,描述了構建示例所需的內容: 對於要更改代碼,編譯和構建.deb文件的用戶的說明
他們聲明的一件事是,您需要安裝libssl-dev
,它將自動安裝libssl1.0.0
。 該軟件包包含libcrypto.so.1.0.0
和libssl.so.1.0.0
。
因此,運行sudo apt-get install libssl-dev
可能會解決您的問題。
但是:您不是直接在arm系統上構建代碼,而是在x86 / 64系統上構建代碼。 我不確定鏈接是否可以正常工作。
我能夠正確構建。 自開始以來,始終是鏈接器路徑問題。 但是,由於我缺乏Eclipse和linux的專業知識,因此無法找到原因。 將我的觀察結果發布給其他人。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.