Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Android - Undefined reference to functions which are using string  (Read 4857 times)

0 Members and 1 Guest are viewing this topic.

Macron

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
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.

ChronicRat

  • Sr. Member
  • ****
  • Posts: 327
  • C++ programmer
    • View Profile
    • My blog
Re: Android - Undefined reference to functions which are using string
« Reply #1 on: February 24, 2015, 07:50:45 pm »
Try "gnustl"

Macron

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Re: Android - Undefined reference to functions which are using string
« Reply #2 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
 
.

ChronicRat

  • Sr. Member
  • ****
  • Posts: 327
  • C++ programmer
    • View Profile
    • My blog
Re: Android - Undefined reference to functions which are using string
« Reply #3 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.

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Android - Undefined reference to functions which are using string
« Reply #4 on: February 25, 2015, 08:12:29 am »
Might be library ordering. Change it in your Android.mk and see if it makes a difference.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

Macron

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Re: Android - Undefined reference to functions which are using string
« Reply #5 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.

ChronicRat

  • Sr. Member
  • ****
  • Posts: 327
  • C++ programmer
    • View Profile
    • My blog
Re: Android - Undefined reference to functions which are using string
« Reply #6 on: February 25, 2015, 06:44:16 pm »
Use "LOCAL_WHOLE_STATIC_LIBRARIES" instead of "LOCAL_STATIC_LIBRARIES" where sfml-main in Android.mk.

Macron

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Re: Android - Undefined reference to functions which are using string
« Reply #7 on: February 25, 2015, 08:16:59 pm »
Thank you @ChronicRat very much, that worked :)!