Setting up NDK library in Eclipse

liortal53liortal53
edited August 2013 in Native
Hi,

Currently i'm editing code using a text editor, but i'd like to import the native libraries for Android to work from within Eclipse.

How can i do this?

It seems that there are a number of different "projects" supplied (demo, photon-client, commons, loadbalancing, etc).

All of these reside in different folders and i don't believe these can be imported into eclipse "as-is".

Is there any recommended way to do this?

I assume that once i import all code files into my eclipse project i would also have to manually edit all build (make) files to correspond to new paths?

Any advice or info would help :)

Thanks
Lior

Comments

  • Sorry, I can't really help you on this one.
    We use Visual Studio, vsandroid and WinGDB for Android NDK development and don't have a lot of experience with Eclipse. I am sorry, but we can't support additional IDEs
  • edited August 2013
    I guess it probably isn't relevant anymore but here is how I did it. It is not elegant but works.

    I assume you have Eclipse set up for NDK development.

    Copy the root folder of the SDK into your JNI directory and rename it to "Photon". You can delete all the directories within this folder with exception of "Photon-cpp","Common-cpp" and "LoadBalancing-cpp".

    Now copy "Photon-cpp", "Common-cpp" and "LoadBalancing-cpp" into your JNI directory. Delete all the subdirectories within these with the exception of "inc".

    Attached is a screenshot of my JNI directory.

    Now modify your Android.mk in order to link the static libraries correctly. For reference my makefile looks like this:
    LOCAL_PATH := $(call my-dir)

    #Shared Library

    include $(CLEAR_VARS)

    LOCAL_MODULE := game_shared

    LOCAL_MODULE_FILENAME := libgame

    LOCAL_SRC_FILES := hellocpp/main.cpp

    FILE_LIST := $(wildcard $(LOCAL_PATH)/../../Classes/*.cpp)

    LOCAL_SRC_FILES += $(FILE_LIST:$(LOCAL_PATH)/%=%)


    LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes \
    $(LOCAL_PATH)/../../proj.ios/tanktrouble/libs/Box2d

    LOCAL_STATIC_LIBRARIES := photon-cpp-static-prebuilt common-cpp-static-prebuilt loadbalancing-cpp-static-prebuilt

    LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static cocosdenshion_static cocos_extension_static box2d_static cocos_curl_static

    include $(BUILD_SHARED_LIBRARY)


    $(call import-module,CocosDenshion/android) \
    $(call import-module,cocos2dx) \
    $(call import-module,extensions) $(call import-module,external/Box2d)

    $(call import-add-path, $(shell pwd)Jni/Photon/Photon-cpp)
    $(call import-add-path, $(shell pwd)jni/Photon/Common-cpp)
    $(call import-add-path, $(shell pwd)jni/Photon/LoadBalancing-cpp)
    $(call import-module,common-cpp-prebuilt)
    $(call import-module,photon-cpp-prebuilt)
    $(call import-module,loadbalancing-cpp-prebuilt)

    You can of course ignore the Cocos2d and Box2d references.

    Finally, if you haven't already you need the following in your Application.mk
    APP_STL := stlport_static
    APP_CPPFLAGS := -frtti
Sign In or Register to comment.