PiotrK
PiotrK

Reputation: 4453

unsatisfied link error on android when using any function from <math.h> in natives (NDK)

I'm getting famous unsatisfied link error when I'm trying to launch my C++ based app on Android. I've tried several ways to solve this out and found out that when I comment out all calls to math.h functions (like sin or sqrt) the application launches correctly.

I am linking my .so library only with libGLESv1_CM.a and in Java I call:

static {
    try
    {
        System.loadLibrary("GLESv1_CM");
        System.loadLibrary("Game");
    }
    catch(UnsatisfiedLinkError error)
    {
        Log.e("MyGame", "Failed to launch game");
    }
}

Am I missing something?

Upvotes: 4

Views: 2723

Answers (1)

richq
richq

Reputation: 56478

You should link it with libm. Add the following to your Android.mk file:

LOCAL_LDLIBS += -lm

Upvotes: 4

Related Questions