Search code examples
androidc++android-ndkjava-native-interface

Undefined reference error while compiling project (ANDROID NDK)


I am working with the Android NDK and I am facing this problem. I am getting following error;

22:30:09 **** Incremental Build of configuration Default for project MrBlueFramework ****
"D:\\Android_Development\\Android_NDK\\ndk-build.cmd" all 
Android NDK: WARNING: APP_PLATFORM android-19 is larger than android:minSdkVersion 8 in ./AndroidManifest.xml    
[armeabi] Compile++ thumb: MrBlueFramework <= MrBlueFramework.cpp
[armeabi] SharedLibrary  : libMrBlueFramework.so
D:/Android_Development/Android_NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/MrBlueFramework/MrBlueFramework.o: in function android_main:jni/MrBlueFramework.cpp:11: error: undefined reference to 'Framework::Application::Application(android_app*)'
D:/Android_Development/Android_NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/MrBlueFramework/MrBlueFramework.o: in function android_main:jni/MrBlueFramework.cpp:11: error: undefined reference to 'Framework::Application::~Application()'
collect2: ld returned 1 exit status
make.exe: *** [obj/local/armeabi/libMrBlueFramework.so] Error 1

Here is what my hierarchy looks like;

enter image description here

Here is my android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := MrBlueFramework
LOCAL_SRC_FILES := MrBlueFramework.cpp \
                   Framework/Application/Application.cpp\
LOCAL_C_INCLUDES        := $(LOCAL_PATH)
LOCAL_LDLIBS    := -llog -landroid -lEGL -lGLESv2
LOCAL_STATIC_LIBRARIES := android_native_app_glue

include $(BUILD_SHARED_LIBRARY)
$(call import-module,android/native_app_glue)

Here is content of Application.h

#include <android_native_app_glue.h>

namespace Framework
{
    class Application
    {
    private:

    public:
        Application(android_app *state);
        virtual ~Application();

        bool Initialize();
        void Run();

    };
}

And here is main class (mrblueframework.cpp)

#include <jni.h>
#include <android_native_app_glue.h>
#include "Framework\Application\Application.h"

using namespace Framework;

void android_main(android_app *state)
{
    app_dummy();

    Application app(state);
}

I don't understand what I am doing wrong, I am including my Application.h file on top but stills it didn't find it. Please help me regarding this.


Solution

  • LOCAL_SRC_FILES := MrBlueFramework.cpp
    

    Application.cpp is not there.