Linking target libraries from different tree branch
Unsolved
Mobile and Embedded
-
I am trying to build a Qt for Android application and I have a root project that looks like this:
root | |- CMakeList.txt |- Project_A <- shared object | `- CMakeList.txt `- Project_B <- actual app `- CMakeList.txt
Now,
Project_B
depends onProject_A
.Project_A
builds the a shared object -libProject_A_x86_64.so
.In
Project_B
, I have the following configurations:... target_include_directories(cook-ui-modular-qt PUBLIC ../Project_A ) if(ANDROID) set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android" CACHE INTERNAL "") set(LIBS ${CMAKE_BINARY_DIR}/Project_A/libProject_A_${ANDROID_ABI}.so) target_link_libraries(root PUBLIC ${LIBS}) set(ANDROID_EXTRA_LIBS ${LIBS} CACHE INTERNAL "") endif() ...
Even though have these linked, I still get the following error:
E AndroidRuntime: FATAL EXCEPTION: qtMainLoopThread E AndroidRuntime: Process: org.qtproject.example.cook_ui_modular_qt, PID: 3484 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: library "libProject_A_x86_64.so" not found: needed by /data/app/~~z1ZkaaXPy7l45CcQdoiWxA==/org.qtproject.example.cook_ui_modular_qt-piF9pyelBLjV1RLkvk0wIA==/lib/x86_64/libcook-ui-modular-qt_x86_64.so in namespace classloader-namespace E AndroidRuntime: at java.lang.Runtime.load0(Runtime.java:939) E AndroidRuntime: at java.lang.System.load(System.java:1628) E AndroidRuntime: at org.qtproject.qt.android.QtNative$4.run(QtNative.java:516) E AndroidRuntime: at org.qtproject.qt.android.QtThread$2.run(QtThread.java:87) E AndroidRuntime: at org.qtproject.qt.android.QtThread$1.run(QtThread.java:61) E AndroidRuntime: at java.lang.Thread.run(Thread.java:923)
This basically means that the
libProject_A_x86_64.so
is not found. I am not sure how to make this file available to the apk. Any help on this would be appreciated. -
A hack that I had to do for this to work is to manually copy the
so
file.if(ANDROID) add_custom_command(TARGET cook-ui-modular-qt POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/App/ConnectedSocket/libConnectedSocket_${ANDROID_ABI}.so ${CMAKE_BINARY_DIR}/App/UserInterface/android-build/libs/${ANDROID_ABI}/libConnectedSocket_${ANDROID_ABI}.so ) endif()
This is obviously not the right way to do it. But I don't know how to do it the right way