Refinitiv / Real-Time-SDK

Other
184 stars 129 forks source link

OPENSSL_ROOT_DIR not fully honoured by the make system #85

Closed linmaosong2018 closed 5 years ago

linmaosong2018 commented 6 years ago

I have been trying to build the C++ SDK on Linux. My system's OpenSSL library is 1.10. Due to issue #83 , I manually installed OpenSSL v1.0.2 under /usr/local/ssl. And I am passing the path to cmake with

cmake -DOPENSSL_ROOT_DIR=/usr/local/ssl -DOPENSSL_LIBRARIES=/usr/local/ssl/lib <sdk_path>

This would appear to work, as cmake outputs the following

-- Found OpenSSL: /usr/local/ssl/lib/libcrypto.a (found version "1.0.2j")

However, the build still fails:

Elektron-SDK1.2.1.linux.rrg/Cpp-C/Eta/Impl/Transport/ripcssldh.c:82:7: error: dereferencing pointer to incomplete type ‘DH {aka struct dh_st}’
     dh->p = (*(cryptoFuncs->bin2bn))(dh512_p, sizeof(dh512_p), NULL);
       ^~
Cpp-C/Eta/Impl/Codec/CMakeFiles/librssl_shared.dir/build.make:998: recipe for target 'Cpp-C/Eta/Impl/Codec/CMakeFiles/librssl_shared.dir/__/Transport/ripcssldh.c.o' failed
make[2]: *** [Cpp-C/Eta/Impl/Codec/CMakeFiles/librssl_shared.dir/__/Transport/ripcssldh.c.o] Error 1
CMakeFiles/Makefile2:366: recipe for target 'Cpp-C/Eta/Impl/Codec/CMakeFiles/librssl_shared.dir/all' failed

Diagnosing further with gcc -E, it looks like the Eta build doesn't honour what has been set by cmake

gcc -E <flags omitted>   -o CMakeFiles/librssl_shared.dir/__/Transport/ripcssldh.c.o   -c <path>/Elektron-SDK1-4/setup/Elektron-SDK1.2.1.linux.rrg/Cpp-C/Eta/Impl/Transport/ripcssldh.c
In file included from /usr/include/inttypes.h:25:0,
                 from /usr/include/openssl/e_os2.h:248,
                 from /usr/include/openssl/bio.h:13,

So it is still looking at the system's default OpenSSL under /usr/include/.

MitchellKato commented 6 years ago

This appears to be a bug with the ETA CMake. As a temporary measure, does this work if you manually set OPENSSL_INCLUDE_DIR in Cpp-C/Eta/Impl/Codec/CMakeLists.txt as the following?

    target_include_directories(librssl
                                PUBLIC
                                    $<BUILD_INTERFACE:${Eta_SOURCE_DIR}/Include/Codec>
                                    $<BUILD_INTERFACE:${Eta_SOURCE_DIR}/Include/Util>
                                    $<BUILD_INTERFACE:${Eta_SOURCE_DIR}/Include/Transport>
                                    $<BUILD_INTERFACE:${Eta_SOURCE_DIR}/Impl/Util/Include>
                                PRIVATE
                                    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
                                    $<BUILD_INTERFACE:${Eta_SOURCE_DIR}/Impl/Transport>
                                    $<BUILD_INTERFACE:${Eta_SOURCE_DIR}/Include>
                                    $<BUILD_INTERFACE:${Eta_SOURCE_DIR}/Utils/zlib>
                                    $<BUILD_INTERFACE:${Eta_SOURCE_DIR}/Utils/Lzf>
                $<BUILD_INTERFACE:${OPENSSL_INCLUDE_DIR}>
                                )

As noted in the #83, we are updating our OpenSSL usage, and will have support for OpenSSL 1.1.0 in a future release.

linmaosong2018 commented 5 years ago

Many thanks, @MitchellKatoTR , this is very helpful. Although, it seems target libssl_shared needs the same fix, so the below is the full fix:

    target_include_directories(librssl
                                PUBLIC
                                    $<BUILD_INTERFACE:${Eta_SOURCE_DIR}/Include/Codec>
                                    $<BUILD_INTERFACE:${Eta_SOURCE_DIR}/Include/Util>
                                    $<BUILD_INTERFACE:${Eta_SOURCE_DIR}/Include/Transport>
                                                                        $<BUILD_INTERFACE:${Eta_SOURCE_DIR}/Impl/Util/Include>
                                PRIVATE
                                                                        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
                                    $<BUILD_INTERFACE:${Eta_SOURCE_DIR}/Impl/Transport>
                                    $<BUILD_INTERFACE:${Eta_SOURCE_DIR}/Include>
                                    $<BUILD_INTERFACE:${Eta_SOURCE_DIR}/Utils/zlib>
                                    $<BUILD_INTERFACE:${Eta_SOURCE_DIR}/Utils/Lzf>
                                    $<BUILD_INTERFACE:${OPENSSL_INCLUDE_DIR}>
                                )

    add_library( librssl_shared SHARED
                        ${rsslSrcFiles} ${rsslWinInetSrcFiles} ${rsslWinRCFiles} rsslVersionShared.c )

    target_include_directories(librssl_shared
                                PUBLIC
                                    $<BUILD_INTERFACE:${Eta_SOURCE_DIR}/Include/Codec>
                                    $<BUILD_INTERFACE:${Eta_SOURCE_DIR}/Include/Util>
                                    $<BUILD_INTERFACE:${Eta_SOURCE_DIR}/Include/Transport>
                                                                        $<BUILD_INTERFACE:${Eta_SOURCE_DIR}/Impl/Util/Include>
                                PRIVATE
                                                                        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
                                    $<BUILD_INTERFACE:${Eta_SOURCE_DIR}/Impl/Transport>
                                    $<BUILD_INTERFACE:${Eta_SOURCE_DIR}/Include>
                                    $<BUILD_INTERFACE:${Eta_SOURCE_DIR}/Utils/zlib>
                                    $<BUILD_INTERFACE:${Eta_SOURCE_DIR}/Utils/Lzf>
                                    $<BUILD_INTERFACE:${OPENSSL_INCLUDE_DIR}>
                                )
CEAndrews95 commented 5 years ago

@linmaosong2018 did adding those $<BUILD_INTERFACE>:${OPENSSL_INCLUDE_DIR} lines help complete the build by any chance?

I was running into the same errors with using an updated version of OpenSSL (1.1.0g) but then manually installed 1.0.2p in my usr/local folder and re-did the cmake builds with the updated -DOPENSSL_ROOT_DIR variable but still ran into the same pointer de-referencing error.

linmaosong2018 commented 5 years ago

@CEAndrews95 yes it worked for me with the workaround. Did you make the change for both librssl and librssl_shared (see above)?

The ideal fix would be what @MitchellKato mentioned: support for a newer version of openssl. Not sure if that's already implemented/released.

vlevendel commented 5 years ago

This is been addressed with ESDK1.3.0. Please let us know if there are additional findings. Closing.