Sign in to follow this  
JonBonazza

Weird compilation errors...

Recommended Posts

Ok, so I wasn't quite sure where to put this, so let me first give some background info to further detail the problem.

I am working on a mostly C++ 2D game engine for the Android OS. As most of you know, the Android OS uses Java as its language of choice, so I am making heavy use of the JNI and the Android NDK. Now, I got all of the hooks working right, so I know the JNI is working correctly, and each of the individual C/C++ libraries I am making use of compiles without error. My problem comes when I try to reference Lua (luabind seems to work fine, but I won't know for sure until I get passed the Lua side of things) from my own code. I get the following compilation errors when I do so:
[media]http://img851.imageshack.us/img851/3586/consoleerror.jpg[/media]


I have done a lot of searching on the error the last few days, but I haven't been able to come up with anything at all. It seems to be a linking issue rather than a compilation issue, as it doesn't come up until everything is finished compiling. Here is the make file I am using for the troublesome code:

[code]

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := main

SDL_PATH := ../sdl

LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(SDL_PATH)/include \
$(LOCAL_PATH)/../luabind \
$(LOCAL_PATH)/../lua/src


# Add your application source files here...

#LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.cpp \
# main.cpp \

LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.cpp \
main.cpp \
Animation.cpp \
Node.cpp \
Renderer.cpp \
GameObject.cpp \
Video.cpp \
Texture2D.cpp \
Globals.cpp \
Script.cpp



LOCAL_SHARED_LIBRARIES := SDL
LOCAL_STATIC_LIBRARIES := Lua LuaBind SDL_image

LOCAL_LDLIBS := -lGLESv1_CM -llog
LOCAL_CPPFLAGS := -fexceptions

include $(BUILD_SHARED_LIBRARY)
[/code]

I should note that I am not very experienced with make files, so there is a great possibility that it is something wrong in that "code,"

I am really not sure what exactly to add code-wise, but I suppose I will post the code that I have narrowed the problem down to.

[code]


#include "Globals.h"
#include "SDL.h"
#include "Script.h"
#include "GameObject.h"
extern "C"
int main(int argc, char *argv[])
{
init_lua();
free_lua();

return 0;
}
[/code]

init_lua() and free_lua() are declared in Globals.h and defined in Globals.cpp, and are simply a wrapper for lua_open() and lua_close() using a global lua_State pointer that is also declared in Globals.h.

I should also mention that if I remove the two methods from the main function, it compiles fine.

Share this post


Link to post
Share on other sites
That's what I was thinking, but it's odd. I specify in my Application.mk (which the Android NDK says to name it) that I want the compilation to us GNU STL. stdc++ is includeded in the STL library, right? Or am I mistaken?

Share this post


Link to post
Share on other sites
It seems I was wrong. According to wiki
[quote]
The C++ Standard Library is based upon conventions introduced by the [url="http://en.wikipedia.org/wiki/Standard_Template_Library"][color="#0645ad"]Standard Template Library[/color][/url] (STL). Although the C++ Standard Library and the STL share many features, neither is a strict superset of the other.
[/quote]


I will try explicitly specifying to link with the stdc++ library.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this