Setup:
Host:-- amd64 VM hosting Ubuntu Mate 15.10 with Eclipse Mars x64 installed. Also Linaro x64 toolchain installed
Target:-- armhf Ubuntu Mate 15.10 Raspberry Pi
Issue
I am trying to cross compile an existing code I found on git However I am unable to do so due to linker error. The project, has a compiled lib mqtt3as.so which looks for libcrypt and libssl. Those are not found by linker. I should mention that I tried below steps..
-- Git code builds fine on Raspberry Pi
-- Host to Target cross compiler works fine with Hello_world code. Deploy and Debug works
-- NFS mounted /lib and /usr/lib from Raspi to toolchainx64/lib folder
but nothing changes. I understand that the issue is related to linker unable to find the libraries. I have tried to follow all possible advice I googled. Below is log from eclipse on host. I can share verbose log if needed.
Literally run out of ideas now. I have unix experience ..but that was years ago and fairly new to eclipse. Still if need arise, I can learn and explore.
Log
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)