设置:
主机: - 安装了Eclipse Mars x64的amd64 VM托管Ubuntu Mate 15.10。还安装了Linaro x64工具链
目标: - armhf Ubuntu Mate 15.10 Raspberry Pi
问题
我正在尝试交叉编译existing code I found on git 但是由于链接器错误,我无法这样做。 该项目有一个编译的lib mqtt3as.so,它查找libcrypt和libssl。链接器找不到那些。我应该提一下,我尝试了以下步骤..
- 在Raspberry Pi上构建Git代码
- Host to Target交叉编译器可以正常使用Hello_world代码。部署和调试工作
- 从Raspi到toolchainx64 / lib文件夹的NFS安装/ lib和/ usr / 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)
答案 0 :(得分:0)
您的构建系统缺少2个库:createTextRepresentation( ? labyrinth)
和libcrypto.so.1.0.0
。
开发人员在他们的存储库中添加了一个额外的部分,描述了构建示例所需的内容:Note for users who want to change the code, compile and build the .deb file
他们说的一件事是你需要安装libssl.so.1.0.0
,它会自动安装libssl-dev
。此程序包包含libssl1.0.0
和libcrypto.so.1.0.0
。
因此,运行libssl.so.1.0.0
可能会解决您的问题。
但是:您不是直接在arm系统上构建代码,而是在x86 / 64系统上构建代码。我不确定链接是否会起作用。
答案 1 :(得分:0)
我能够正确构建。从一开始它始终是链接器路径问题。但由于我缺乏Eclipse和Linux的专业知识,我无法找到原因。发表我对其他人的观察。