[cmake-developers] cmake's built-in support for android using nvidia nsight tegra
Peter List
pem.list at gmail.com
Tue Aug 25 02:09:50 EDT 2015
I worked around that error by editing SDL_android_main.c:
extern "C"
{
/* Called before SDL_main() to initialize JNI bindings in SDL library */
extern void SDL_Android_Init(JNIEnv* env, jclass cls);
}
So I'm at least able to build again now... Though it still crashes when I
try to run the APK...
On Tue, Aug 25, 2015 at 12:57 AM, Peter List <pem.list at gmail.com> wrote:
> I'm now attempting to build a simple SDL2 Android application with CMake's
> built-in Android support (uses nvidia tegra nsight for visual studio 2010)
>
> SDL2-2.0.3 does not appear to have a NativeActivity example so I'm
> attempting to use its android-project folder that includes
> "SDL2-2.0.3\android-project\src\org\libsdl\app\SDLActivity.java" instead.
>
> I'm able to compile my libpemDemos.so project with SDL2 code this way for
> armabi-v7a
>
> I also compiled libSDL2.so for armabi-v7a using ndk-build (not nvidia
> tegra nsight), and I'm able to reference it from my pemDemos.vcxproj
>
> I verified my pemDemos.vcxproj linker step does includes this:
> -L"[path]/SDL2-2.0.3/libs/armeabi-v7a" "-lSDL2"
>
> However, I'm getting a linker error when I try to add SDL_android_main.c
> to my build:
>
> 1> pemDemos.dir/Debug/SDL_android_main.o: In function
> `Java_org_libsdl_app_SDLActivity_nativeInit(_JNIEnv*, _jclass*, _jobject*)':
> 1> [path]\SDL2-2.0.3\src\main\android\SDL_android_main.c(23): undefined
> reference to `SDL_Android_Init(_JNIEnv*, _jclass*)'
> 1>collect2.exe : error : ld returned 1 exit status
>
> If I comment out the following one line then I can build my libpemDemos.so
> again:
>
> SDL_Android_Init(env, cls);
>
> However that of course fails when I try to run it.
>
> I don't understand why the linker doesn't see `SDL_Android_Init(_JNIEnv*,
> _jclass*)'. I have "-lSDL2" (and I know the linker is finding libSDL.so
> because it gives an error if I change vcxproj settings to do "-lSDLzzz"
> instead of "-lSDL"). Plus I even verified that libSDL2.so has
> SDL_Android_Init():
>
> >readelf -Ws [path]\SDL2-2.0.3\libs\armeabi-v7a\libSDL2.so | grep
> SDL_Android_Init
> 216: 0002f60d 332 FUNC GLOBAL DEFAULT 8 SDL_Android_Init
>
> So why doesn't my linker step find SDL_Android_Init()?
>
> thank you for any leads
>
>
>
>
> On Mon, Aug 24, 2015 at 8:20 PM, Peter List <pem.list at gmail.com> wrote:
>
>> Per Brad's suggestion, I removed this line from my CMakeLists.txt:
>>
>> add_library(${PROJECT_NAME} SHARED ${SRC_LIST})
>>
>> And I added these lines:
>>
>> set(CMAKE_ANDROID_GUI TRUE)
>> set(CMAKE_ANDROID_API 19) # Kindle Fire HD 6
>> set(CMAKE_ANDROID_API_MIN 19) # Kindle Fire HD 6
>> add_executable(${PROJECT_NAME} ${SRC_LIST})
>>
>> I am now able to generate a Visual Studio 2010 pemDemos.sln that includes
>> a pemDemos.vcxproj with a configuration properties section "Ant Built".
>> From inside Visual Studio, I'm able to build an APK and then ctrl+F5 to run
>> it on my device.
>>
>> Unfortunately, cmake did not generate AndroidManifest.xml, so I had to
>> supply my own using the aforementioned execute_process() with android.bat.
>>
>> At this point my app just displays a "Hello World, PemActivity" message
>> that it gets from "build-android\android\res\layout\main.xml". So it's not
>> using "android_native_app_glue.c,h" to point to my "main.cpp" code in
>> "libpemDemos.so" yet. So maybe cmake doesn't do that part automatically
>> for me? I also don't see a tutorial or simple hello world demo project for
>> this... However, I can at least use AndroidNativeApp.vcxproj as a
>> reference.
>>
>> thank you & best regards
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> On Mon, Aug 24, 2015 at 9:49 AM, Brad King <brad.king at kitware.com> wrote:
>>
>>> On 08/23/2015 04:44 PM, Peter List wrote:
>>> > How do I tell cmake to include "Ant Build" in my vcxproj, so that
>>> > it will package my project into an APK? I can generate vcxproj
>>> > that builds a Tegra-Android *.so file, but it does not build me
>>> > an APK, and my vcxproj is missing the "Ant Build" property section.
>>>
>>> You need to set the ANDROID_GUI target property on an exe:
>>>
>>> http://www.cmake.org/cmake/help/v3.3/prop_tgt/ANDROID_GUI.html
>>>
>>> Additional settings have been added in post-3.3 development:
>>>
>>> VS: Add more Nsight Tegra generator Android property settings
>>> http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8c0afaf4
>>>
>>> -Brad
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20150825/90a85281/attachment.html>
More information about the cmake-developers
mailing list