Skip to Content
0
Sep 14, 2023 at 04:13 PM

Static build to protect rfc libs?

159 Views Last edit Sep 16, 2023 at 02:41 PM 2 rev

Hello all,

I am building a static app, which properly links all system libraries needed for the app itself, so at the end i have one exe file only containing all libraries as static, so they ar enot exposed.

Unfortunately SAP RFC libraries are not included, therefore on other devices it throws an error that its missing sapnwrfc.dll.

Obviously I need to protect those libs in order not to be exposed for end customer...

So my question is, are those libs compiled as shared or static?

If shared then i could see why visual studio/QT creator wont include them with all others static libs.

Or does it need a specific definition?

here is my cmake:

set_target_properties(${PROJECT} PROPERTIES
    WIN32_EXECUTABLE TRUE
    INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_LIST_DIR}/nwrfcsdk/include"
)
...
set(SAPNWRFC_LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/nwrfcsdk/lib")
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
    set(SAPNWRFC_LIB_FILES sapnwrfc.lib libsapucum.lib)
else()
    set(SAPNWRFC_LIB_FILES -lsapnwrfc -lsapucum)
endif()
target_link_directories(${PROJECT} PRIVATE ${SAPNWRFC_LIB_DIR})
...
target_link_libraries(${PROJECT}
    PRIVATE Qt6::Quick
    PRIVATE Qt6::Gui
    PRIVATE ${SAPNWRFC_LIB_FILES}
)
...
target_compile_definitions(${PROJECT} PRIVATE SAPwithUNICODE)
target_compile_definitions(${PROJECT} PRIVATE UNICODE)
target_compile_definitions(${PROJECT} PRIVATE _UNICODE)
target_compile_definitions(${PROJECT} PRIVATE SAPwithTHREADS)

install(TARGETS ${PROJECT}
    BUNDLE DESTINATION .
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})<br>