set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl, --allow-shlib-undefined" )
set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl, -undefined" )
set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} -undefined dynamic_lookup")
Hi,
I'm trying to build a dynamic library with some undefined references (basically calling some functions which belong to other dynamic libraries and they will be loaded before loading this library) from Android Studio. But with any or all the flags as below I'm getting an error as 'error: undefined reference to 'test_func''. 'test_func' is a function which will be called from a.so, but can be exposed by either b.so or c.so. I would like the function test_func( ) to be linked to a library which I would load with 'dlopen( )' at runtime (b.so or c.so), so that I can load different libraries which expose test_func( ) method for different invocations of my app. Can any one please tell me the correct flags to be set in my CMakeLists.txt file to achieve this or if cannot be achieved in Android-Ndk. This is similar to what Linux allows, so I guess I'm missing something.
Tried below flag settings in CMakeLists.txtset( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl, --allow-shlib-undefined" )
set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl, -undefined" )
set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} -undefined dynamic_lookup")
Android NDK version:
Pkg.Desc = Android NDK
Pkg.Revision = 19.2.5345600
Thanks,Raj.
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/CAOpHf7MqgZEPwbgEPjgdNO5%3DxG7AmbdLc559fipy2CF948dsxA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/CAA2GJqWDOQny-X79p5Uisrxzh3ODBWiwt%2B4Vf7N6t11ZNBvjog%40mail.gmail.com.
Thanks for your time J Decker, Instead of using the function pointers won't it be possible to link the library with the functions which are exposed by already loaded libraries. I would like to give a try by disabling the --no-undefined flag from the linker options.With verbose logging of cmake, how can we disable the - - no-undefined flag from the linker flags, it seems to get added by default.LANGUAGE_COMPILE_FLAGS = -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -mstackrealign -fno-addrsig -Wa,--noexecstack -Wformat -Werror=format-security -stdlib=libc++ -std=c++11 -frtti -fexceptions -O0 -fno-limit-debug-info
LINK_FLAGS = -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,-allow-shlib-undefined -Wl,-undefined
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/CAOpHf7NTbPmo--ngdArUc5TSfSv-PZRZdZcct_F1xBQDsOyG0Q%40mail.gmail.com.
Thanks for your time and inputs J Decker, and due to some unavoidable circumstances I couldn't reply earlier. Now, I'm using the dlopen to load the libraries at run time and link the function pointers using dlsym (instead of relying on undefined references). Got to know that the best way to load the libraries is to use System.loadLibrary("lib.so") calls from Java side. But I want to explicitly do it from C side using dlopen( ) calls only. So, as of now the libraries are placed at '/data/data/<package>/libs' and I'm using this path, but the problem is that the path is undocumented. As per the answer in (https://stackoverflow.com/questions/15719149/how-to-integrate-native-runtime-library-with-dlopen-on-ndk), the best way to obtain the path to the libraries is to use '/proc' and 'derive from that the path to other libs' - I couldn't find more details on how to use '/proc' to obtain the path to the libraries. Can anyone please point me to a tutorial or an example from which I can refer.
Another question: If we have an update to a dynamic library, during my program start-up, can I copy the updated library from another folder to my project libraries folder ('/data/data/<package>/libs' or the one obtained with the help of '/proc'). We would like to do this to avoid giving an updated APK when ever we would have an update to one of our dynamic libraries ? Is it recommended not to use such methods or is it valid on Android platform..
Thanks,
Raj.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/CAA2GJqWgiOJMs9rwGjb6Dycin%2Byj49EFRnJEuQYqmgUbcttGBg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/CAOpHf7NjnSa%3DrU04mBqK_%3D9xCZfrWj0gheg1EtOv0mPbNL-S2Q%40mail.gmail.com.
Thanks,Raj.
To unsubscribe from this group and stop receiving emails from it, send an email to andro...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/CAOpHf7MqgZEPwbgEPjgdNO5%3DxG7AmbdLc559fipy2CF948dsxA%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to andro...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/CAA2GJqWDOQny-X79p5Uisrxzh3ODBWiwt%2B4Vf7N6t11ZNBvjog%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to andro...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/CAOpHf7NTbPmo--ngdArUc5TSfSv-PZRZdZcct_F1xBQDsOyG0Q%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to andro...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/4ee4455f-7ce3-45a9-bf3c-5b49cac03e71%40googlegroups.com.
Well, I assumed that one library would be with all the other libraries so I have this bit of code
Well, I assumed that one library would be with all the other libraries so I have this bit of codethat reads /proc/self/maps and finds its own name (defined as part of the compile options TARGET_NAME as a string), and gets the path from that. Works on any system that puts libraries in some place.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/4ee4455f-7ce3-45a9-bf3c-5b49cac03e71%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/8fc48a05-d272-4174-b700-cfafed027a6b%40googlegroups.com.