SFML community forums

Help => General => Topic started by: Macron on February 24, 2015, 06:06:42 pm

Title: Android - Undefined reference to functions which are using string
Post by: Macron on February 24, 2015, 06:06:42 pm
Hi. I wanted to make app on Android, so I downloaded SFML<andfixes branch>, got it compiled and made project from example files. But when I build it with ndk-build, I get these errors:
(click to show/hide)
My Android.mk:
(click to show/hide)
and my Application.mk
(click to show/hide)

Code is SFML example.
If I compile with another APP_STL option, apk gets compiled, but doesn't want to work.
Title: Re: Android - Undefined reference to functions which are using string
Post by: ChronicRat on February 24, 2015, 07:50:45 pm
Try "gnustl"
Title: Re: Android - Undefined reference to functions which are using string
Post by: Macron on February 24, 2015, 09:33:36 pm
With gnustl_shared I get
sfml-activity(2546): sfml-activity: Undefined symbol ANativeActivity_onCreate
and with gnustl_static I get errors:
 dlopen("/data/app-lib/com.example.sfml-1/libgnustl_shared.so"): Cannot load library: load_library(linker.cpp:745): library "/data/app-lib/com.example.sfml-1/libgnustl_shared.so" not found
 
.
Title: Re: Android - Undefined reference to functions which are using string
Post by: ChronicRat on February 25, 2015, 06:37:54 am
Try something like this:
SFMLActivity.cpp
   // Load our libraries in reverse order
    //loadLibrary("c++_shared", lJNIEnv, ObjectActivityInfo);
    loadLibrary("sndfile", lJNIEnv, ObjectActivityInfo);
    loadLibrary("openal", lJNIEnv, ObjectActivityInfo);
 
If you using static stl, so you don't need to 'loadLibrary' for it.
Title: Re: Android - Undefined reference to functions which are using string
Post by: binary1248 on February 25, 2015, 08:12:29 am
Might be library ordering (http://www.sfml-dev.org/faq.php#build-link). Change it in your Android.mk and see if it makes a difference.
Title: Re: Android - Undefined reference to functions which are using string
Post by: Macron on February 25, 2015, 05:00:05 pm
@ChronicRat With that, I still get
sfml-activity: Undefined symbol ANativeActivity_onCreate
 
error.
@binary1248 Nothing seems to change with other library order.
Title: Re: Android - Undefined reference to functions which are using string
Post by: ChronicRat on February 25, 2015, 06:44:16 pm
Use "LOCAL_WHOLE_STATIC_LIBRARIES" instead of "LOCAL_STATIC_LIBRARIES" where sfml-main in Android.mk.
Title: Re: Android - Undefined reference to functions which are using string
Post by: Macron on February 25, 2015, 08:16:59 pm
Thank you @ChronicRat very much, that worked :)!