Problem with cross compilation of Paho C (ARM)

Issue

I need help because I try to cross compile the paho library in c for my arm device.

I use an ubuntu 20.04 virtual machine and my cross compiler is gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf_5.3_sub1.0.3.tgz. Here the differents steps.

git clone https://github.com/eclipse/paho.mqtt.c.git

sudo apt-get update
sudo apt-get install build-essential gcc make cmake cmake-gui cmake-curses-gui
sudo apt-get install fakeroot fakeroot devscripts dh-make lsb-release
sudo apt-get install libssl-dev 
sudo apt-get install doxygen graphviz
mkdir build.paho
cd build.paho

I’ve created a file "linaro.cmake" in the cmake folder of the paho project

 # specify the cross compiler

SET(CMAKE_C_COMPILER    /opt/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc)
SET(CMAKE_CXX_COMPILER  /opt/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++)
SET(CMAKE_STRIP /opt/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-strip)

#SET(OPENSSL_LIB_SEARCH_PATH opt/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/lib)
#SET(OPENSSL_INC_SEARCH_PATH opt/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/include/openssl)
#SET(OPENSSL_SEARCH_PATH "/opt/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/lib;/opt/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/bin/")

SET(OPENSSL_ROOT_DIR /opt/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/bin)
SET(OPENSSL_LIBRARIES /opt/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/lib)
#SET(OPENSSL_LIBRARIES /opt/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/include/openssl)
SET(OPENSSL_INCLUDE_DIR /opt/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/include/openssl)
SET(OPENSSL_CRYPTO_LIBRARY /opt/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/include/openssl/libcrypto.so)
SET(OPENSSL_SSL_LIBRARY /opt/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/lib/libssl.so)

SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_PROCESSOR arm)
SET(CMAKE_SYSTEM_VERSION 1)

My problem, when I launch the command

cmake \
-GNinja \
-DPAHO_WITH_SSL=TRUE \
-DPAHO_BUILD_SAMPLES=TRUE \
-DPAHO_BUILD_DOCUMENTATION=TRUE \
-DCMAKE_TOOLCHAIN_FILE=../cmake/linaro.cmake ..

I have multiple warning like

— The C compiler identification is GNU 5.3.1
— Check for working C compiler: /opt/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
— Check for working C compiler: /opt/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
— works
— Detecting C compiler ABI info
— Detecting C compiler ABI info – done
— Detecting C compile features
— Detecting C compile features – done
— CMake version: 3.16.3
— CMake system name: Linux
— Timestamp is 2021-05-04T12:39:01Z
— Found OpenSSL: /opt/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/bin/libcrypto.so

— Configuring done CMake Warning (dev) at src/CMakeLists.txt:200 (ADD_LIBRARY): Policy CMP0028 is not set: Double colon in target
name means ALIAS or IMPORTED target. Run "cmake –help-policy
CMP0028" for policy details. Use the cmake_policy command to set the
policy and suppress this warning.

Target "paho-mqtt3cs" links to target "OpenSSL::Crypto" but the
target was not found. Perhaps a find_package() call is missing for
an IMPORTED target, or an ALIAS target is missing? This warning is
for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) at src/CMakeLists.txt:201 (ADD_LIBRARY): Policy
CMP0028 is not set: Double colon in target name means ALIAS or
IMPORTED target. Run "cmake –help-policy CMP0028" for policy
details. Use the cmake_policy command to set the policy and suppress
this warning.

Target "paho-mqtt3as" links to target "OpenSSL::Crypto" but the
target was not found. Perhaps a find_package() call is missing for
an IMPORTED target, or an ALIAS target is missing? This warning is
for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) at src/CMakeLists.txt:332 (ADD_EXECUTABLE):
Policy CMP0028 is not set: Double colon in target name means ALIAS or
IMPORTED target. Run "cmake –help-policy CMP0028" for policy
details. Use the cmake_policy command to set the policy and suppress
this warning.

Target "Sha1TestOpenSSL" links to target "OpenSSL::Crypto" but the
target was not found. Perhaps a find_package() call is missing for
an IMPORTED target, or an ALIAS target is missing? This warning is
for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) at src/CMakeLists.txt:323 (ADD_EXECUTABLE):
Policy CMP0028 is not set: Double colon in target name means ALIAS or
IMPORTED target. Run "cmake –help-policy CMP0028" for policy
details. Use the cmake_policy command to set the policy and suppress
this warning.

Target "Base64TestOpenSSL" links to target "OpenSSL::Crypto" but the
target was not found. Perhaps a find_package() call is missing for
an IMPORTED target, or an ALIAS target is missing? This warning is
for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) at test/CMakeLists.txt:516 (ADD_EXECUTABLE):
Policy CMP0028 is not set: Double colon in target name means ALIAS or
IMPORTED target. Run "cmake –help-policy CMP0028" for policy
details. Use the cmake_policy command to set the policy and suppress
this warning.

Target "test3" links to target "OpenSSL::Crypto" but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing? This warning is for project
developers. Use -Wno-dev to suppress it.

CMake Warning (dev) at test/CMakeLists.txt:1122 (ADD_EXECUTABLE):
Policy CMP0028 is not set: Double colon in target name means ALIAS or
IMPORTED target. Run "cmake –help-policy CMP0028" for policy
details. Use the cmake_policy command to set the policy and suppress
this warning.

Target "test5" links to target "OpenSSL::Crypto" but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing? This warning is for project
developers. Use -Wno-dev to suppress it.

— Generating done
— Build files have been written to: /home/myhome/Documents/paho.mqtt.c/build.paho

And when I try to launch ninja package

[9/50] Linking C shared library src/libpaho-mqtt3cs.so.1.3.8 FAILED:
src/libpaho-mqtt3cs.so.1.3.8 : &&
/opt/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
-fPIC -Wl,-init,MQTTClient_init -shared -Wl,-soname,libpaho-mqtt3cs.so.1 -o src/libpaho-mqtt3cs.so.1.3.8 src/CMakeFiles/common_ssl_obj.dir/MQTTTime.c.o
src/CMakeFiles/common_ssl_obj.dir/MQTTProtocolClient.c.o
src/CMakeFiles/common_ssl_obj.dir/Clients.c.o
src/CMakeFiles/common_ssl_obj.dir/utf-8.c.o
src/CMakeFiles/common_ssl_obj.dir/MQTTPacket.c.o
src/CMakeFiles/common_ssl_obj.dir/MQTTPacketOut.c.o
src/CMakeFiles/common_ssl_obj.dir/Messages.c.o
src/CMakeFiles/common_ssl_obj.dir/Tree.c.o
src/CMakeFiles/common_ssl_obj.dir/Socket.c.o
src/CMakeFiles/common_ssl_obj.dir/Log.c.o
src/CMakeFiles/common_ssl_obj.dir/MQTTPersistence.c.o
src/CMakeFiles/common_ssl_obj.dir/Thread.c.o
src/CMakeFiles/common_ssl_obj.dir/MQTTProtocolOut.c.o
src/CMakeFiles/common_ssl_obj.dir/MQTTPersistenceDefault.c.o
src/CMakeFiles/common_ssl_obj.dir/SocketBuffer.c.o
src/CMakeFiles/common_ssl_obj.dir/LinkedList.c.o
src/CMakeFiles/common_ssl_obj.dir/MQTTProperties.c.o
src/CMakeFiles/common_ssl_obj.dir/MQTTReasonCodes.c.o
src/CMakeFiles/common_ssl_obj.dir/Base64.c.o
src/CMakeFiles/common_ssl_obj.dir/SHA1.c.o
src/CMakeFiles/common_ssl_obj.dir/WebSocket.c.o
src/CMakeFiles/common_ssl_obj.dir/StackTrace.c.o
src/CMakeFiles/common_ssl_obj.dir/Heap.c.o
src/CMakeFiles/paho-mqtt3cs.dir/MQTTClient.c.o
src/CMakeFiles/paho-mqtt3cs.dir/SSLSocket.c.o
/opt/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/lib/libssl.so -lOpenSSL::Crypto -lc -ldl -lpthread -lrt && : /opt/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/5.3.1/../../../../arm-linux-gnueabihf/bin/ldĀ :
ne peut trouver -lOpenSSL::Crypto collect2: error: ld returned 1 exit
status [11/50] Building C object
src/CMakeFiles/paho-mqtt3as.dir/SSLSocket.c.o ninja: build stopped:
subcommand failed.

Have anybody an idea ?

The strange thing for me is this line
— Found OpenSSL: /opt/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/bin/libcrypto.so even if I indicated another location.

Thanks in advance

Solution

Resolved with a new compiler gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf.

Answered By – JEKES

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published