cpprestsdk icon indicating copy to clipboard operation
cpprestsdk copied to clipboard

Cross compilation for ARM takes wrong OpenSSL library

Open bbDSA opened this issue 6 years ago • 0 comments

When I try to build cpprestsdk for ARM on linux-gnu-x86_64 the OpenSSL library installed for the system and not for the cross compilation environment is choosen. The Debian package libssl1.0.0:armhf ist installed on the system.

The CMake toolchain file is

INCLUDE(CMakeForceCompiler)

SET(CMAKE_SYSTEM_NAME Linux)

SET(CMAKE_C_COMPILER /usr/bin/arm-linux-gnueabihf-gcc )
SET(CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabihf-g++ )

The result of configuring cpprestsdk is:

-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found suitable version "1.0.1t", minimum required is "1.0.0")
-- Performing Test _SSL_LEAK_SUPPRESS_AVAILABLE
-- Performing Test _SSL_LEAK_SUPPRESS_AVAILABLE - Failed

Here the wrong OpenSSL libary is used, the one installed under /usr/lib/arm-linux-gnueabihf/ should be used. The resulting linker command is:

/usr/bin/arm-linux-gnueabihf-g++ -fPIC  -std=c++11 -fno-strict-aliasing  -shared 
    -Wl,-soname,libcpprest.so.2.10 -o ../Binaries/libcpprest.so.2.10 
     <<<< some .o files >>> 
     -Wl,-rpath,/usr/lib/x86_64-linux-gnu: 
     -lpthread /usr/lib/arm-linux-gnueabihf/libz.so 
     /usr/lib/arm-linux-gnueabihf/libboost_random.so.1.71.0 
     /usr/lib/arm-linux-gnueabihf/libboost_system.so.1.71.0 
     /usr/lib/arm-linux-gnueabihf/libboost_thread.so.1.71.0 
     -lpthread 
     /usr/lib/arm-linux-gnueabihf/libboost_filesystem.so.1.71.0
     /usr/lib/arm-linux-gnueabihf/libboost_chrono.so.1.71.0 
     /usr/lib/arm-linux-gnueabihf/libboost_atomic.so.1.71.0 
     /usr/lib/arm-linux-gnueabihf/libboost_date_time.so.1.71.0 
     /usr/lib/arm-linux-gnueabihf/libboost_regex.so.1.71.0 
     /usr/lib/x86_64-linux-gnu/libssl.so 
     /usr/lib/x86_64-linux-gnu/libcrypto.so

What would be the right way for ensuring that the proper OpenSSL installation is used? Alternatively, is there a built-in SSL solution? I also wonder how I can influence the rpath which points to thre wrong directory.

bbDSA avatar Mar 13 '20 15:03 bbDSA