Proper way to link OgreMainStatic to eclipse?

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
User avatar
Argosse
Gnoblar
Posts: 17
Joined: Wed Apr 27, 2011 9:43 pm

Proper way to link OgreMainStatic to eclipse?

Post by Argosse »

Ive built an Android project in eclipse, converted it to a c++/native project. I also have java calling c++ function successfully.

Now my problem is when I go to initialize a new ogre::root build complains undefined reference to Ogre::Root and Ogre::NedAllocMemWhatever...
Ive also included "OgreRoot.h".

I have OgreMain, RenderSystemGLES2 and octree built. Whats the proper way to now link in the libOgreMainStatic.a that I already have built.

Heres my Android.mk.

Code: Select all

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE    := myOgreBase
LOCAL_SRC_FILES := include/myOgreBase.cpp
LOCAL_CFLAGS    := -Werror -fexceptions
LOCAL_C_INCLUDES += C:/Dev/Android/android-ndk-r8/sources/android/native_app_glue
LOCAL_C_INCLUDES += C:/Dev/Android/android-ndk-r8/platforms/android-14/arch-arm/usr/include
LOCAL_C_INCLUDES += C:/Dev/Android/ogre/OgreMain/include
LOCAL_C_INCLUDES += C:/Dev/Android/ogre/Samples/Common/include
LOCAL_C_INCLUDES += C:/Dev/Android/ogre/buildAndroid_2/include
LOCAL_C_INCLUDES += C:/Dev/Android/ogre/RenderSystems/GLES2/include
LOCAL_C_INCLUDES += C:/Dev/Android/ogre/RenderSystems/GLES2/include/EGL
LOCAL_C_INCLUDES += C:/Dev/Android/ogredeps/src/ois/includes
LOCAL_STATIC_LIBRARIES += OgreMainStatic
#LOCAL_LDLIBS := -L$(LOCAL_PATH) -llog -LMyOgreMain
include $(BUILD_SHARED_LIBRARY)
Any help would be greatly appreciated. Also if you could copy and paste my make file with the corrections I would be so so so very greatful. I always have a hard time following instructions on where to put certain lines. Thanks in advance. Im planning on making a tutorial for the process of making a Ogre capable Android project in eclipse. With instructions for jni and functions naming etc etc. Thanks again
User avatar
Argosse
Gnoblar
Posts: 17
Joined: Wed Apr 27, 2011 9:43 pm

Re: Proper way to link OgreMainStatic to eclipse?

Post by Argosse »

Well I solved my own problem. So for anyone ever needing, this is for search. LINKING STATIC OGRE ECLIPSE
Here is my new Android.mk under the jni folder in my project.

Code: Select all

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := myOgreMain
LOCAL_SRC_FILES := /prebuild/libOgreMainStatic.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := freeimage
LOCAL_SRC_FILES := /prebuild/libFreeImage.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := zzip
LOCAL_SRC_FILES := /prebuild/libzziplib.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := freetype
LOCAL_SRC_FILES := /prebuild/libfreetype.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := gles2
LOCAL_SRC_FILES := /prebuild/libRenderSystem_GLES2Static.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE    := myOgreBase
LOCAL_SRC_FILES := include/myOgreBase.cpp
LOCAL_CFLAGS    := -Werror -fexceptions
LOCAL_C_INCLUDES += C:/Dev/Android/android-ndk-r8/sources/android/native_app_glue
LOCAL_C_INCLUDES += C:/Dev/Android/android-ndk-r8/platforms/android-14/arch-arm/usr/include
LOCAL_C_INCLUDES += C:/ogre/OgreMain/include
LOCAL_C_INCLUDES += C:/ogre/Samples/Common/include
LOCAL_C_INCLUDES += C:/ogre/androidBuilt/include
LOCAL_C_INCLUDES += C:/ogre/RenderSystems/GLES2/include
LOCAL_C_INCLUDES += C:/ogre/RenderSystems/GLES2/include/EGL
LOCAL_C_INCLUDES += C:/ogre/AndroidDependencies/include/ois
LOCAL_STATIC_LIBRARIES += myOgreMain gles2 freeimage freetype zzip cpufeatures
LOCAL_LDFLAGS := -llog -lz
include $(BUILD_SHARED_LIBRARY)

$(call import-module,android/cpufeatures)
You just need to prebuild ogre branch 1-9 following the cmake quick start guide. Then copy all the libs into jni/prebuild.

Now ive got a bunch of undefined references to glGetIntegerv in libRenderSystem_GLES2.