In the sample AndroidJNI (ogre/Samples/AndroidJNI), there is a MainActivity.java. I tried to build it in Android Studio. However, it cannot find libOgreJNI.so when executed. How can I generate this so file?
I can build and run the other Android sample (SampleBrowserNDK). But that one is a pure native one using NativeActivity. I would like to use the "traditional" Android way like what AndroidJNI is doing.
Question about AndroidJNI sample
-
- OGRE Team Member
- Posts: 2106
- Joined: Sun Mar 30, 2014 2:51 pm
- x 1132
Re: Question about AndroidJNI sample
did you build the Java Component? If so it should have generated an according android project in ${CMAKE_BINARY_DIR}/OgreJNI,
-
- Gnoblar
- Posts: 17
- Joined: Tue Nov 28, 2017 12:19 am
Re: Question about AndroidJNI sample
Yes. I have enabled Java component, and it generated lots of Java files. I packed them into a Jar file and used it in Android Studio. But there is no so file generated. How can I generate libOgreJNI.so?
-
- OGRE Team Member
- Posts: 2106
- Joined: Sun Mar 30, 2014 2:51 pm
- x 1132
Re: Question about AndroidJNI sample
should be in ${CMAKE_BINARY_DIR}/OgreJNI/libs
-
- Gnoblar
- Posts: 17
- Joined: Tue Nov 28, 2017 12:19 am
Re: Question about AndroidJNI sample
There is a folder named "OgreJNI/libs/armeabi-v7a", but it is empty.
How can I generate the so file. Can you post more detailed command line or a link? Thanks!
How can I generate the so file. Can you post more detailed command line or a link? Thanks!
-
- Gnoblar
- Posts: 17
- Joined: Tue Nov 28, 2017 12:19 am
Re: Question about AndroidJNI sample
i think I know why the so file is not generated. When I run "make OgreJNI", i got a link error saying
"ld: fatal error: -soname: must take a non-empty argument"
I see Components/Java/CMakeLists.txt has a line at the end as:
set_target_properties(${SWIG_MODULE_OgreJNI_REAL_NAME} PROPERTIES NO_SONAME OFF) # workaround for SWIG/ android interop
However, this line does not work.
"ld: fatal error: -soname: must take a non-empty argument"
I see Components/Java/CMakeLists.txt has a line at the end as:
set_target_properties(${SWIG_MODULE_OgreJNI_REAL_NAME} PROPERTIES NO_SONAME OFF) # workaround for SWIG/ android interop
However, this line does not work.
Last edited by redpearl on Tue Nov 28, 2017 8:32 pm, edited 1 time in total.
-
- Gnoblar
- Posts: 17
- Joined: Tue Nov 28, 2017 12:19 am
Re: Question about AndroidJNI sample
More search online, I realized that this "NO_SONAME" tricks works until cmake 3.3 and is ignored from cmake 3.4. Since I am using cmake 3.8, it does not work at all.
Someone suggest to replace the deprecated swig_add_module to swig_add_library. I tried to replace the line:
"swig_add_module(OgreJNI java ${SWIG_INPUT_MODULES})" with
"swig_add_library(OgreJNI LANGUAGE java SOURCES ${SWIG_INPUT_MODULES})"
However, I still get the same error when build OgreJNI. Can anyone guide how to fix it?
BTW: I found that Ogre used extremely old stuffs for Android. I have to manually download a very old version of SDK tools to make the "android" command works. Please make it suitable for the latest Android tools, particularly, Android Studio with gridle.
Someone suggest to replace the deprecated swig_add_module to swig_add_library. I tried to replace the line:
"swig_add_module(OgreJNI java ${SWIG_INPUT_MODULES})" with
"swig_add_library(OgreJNI LANGUAGE java SOURCES ${SWIG_INPUT_MODULES})"
However, I still get the same error when build OgreJNI. Can anyone guide how to fix it?
BTW: I found that Ogre used extremely old stuffs for Android. I have to manually download a very old version of SDK tools to make the "android" command works. Please make it suitable for the latest Android tools, particularly, Android Studio with gridle.
-
- OGRE Team Member
- Posts: 2106
- Joined: Sun Mar 30, 2014 2:51 pm
- x 1132
-
- Gnoblar
- Posts: 17
- Joined: Tue Nov 28, 2017 12:19 am
Re: Question about AndroidJNI sample
Is there any way to generate the so file with cmake 3.8? The NO_SONAME trick failed for cmake 3.3+.
-
- Gnoblar
- Posts: 17
- Joined: Tue Nov 28, 2017 12:19 am
Re: Question about AndroidJNI sample
I finally generated the so file using the most straightforward method -- replacing my cmake to 3.2 version.
However, it would be really nice to modify Ogre itself making it working for latest tools (cmake, NDK, etc.). Otherwise, many people will soon met the same errors and complain about it.
However, it would be really nice to modify Ogre itself making it working for latest tools (cmake, NDK, etc.). Otherwise, many people will soon met the same errors and complain about it.
-
- OGRE Team Member
- Posts: 2106
- Joined: Sun Mar 30, 2014 2:51 pm
- x 1132
Re: Question about AndroidJNI sample
this should allow using CMake 3.2+