一开始在win平台下运行没问题的程序,在eclipse中编译却老是失败,提示undefined reference to 'sqlite3_open'什么的,网上找了很多资料,终于发现原来是cocos2dx的sqlite3只有lib的静态库,只能在win、wp平台上用,真的太坑啦!做事怎么可以做一半呢,Android、ios平台你们不管了么??
Android平台解决方法:
1、下载sqlite包
地址:http://www.sqlite.org/sqlite-amalgamation-3071000.zip
2、解压出来有4个文件,copy到工程目录下,这里我是放到cocos2d/sqlite中,这个目录在步骤4中会用到
4、修改Android.mk
MY_CPP_LIST:=$(wildcard$(LOCAL_PATH)/*.cpp) MY_CPP_LIST+=$(wildcard$(LOCAL_PATH)/hellocpp/*.cpp) MY_CPP_LIST+=$(wildcard$(LOCAL_PATH)/../../Classes/*.cpp) MY_CPP_LIST+=$(wildcard$(LOCAL_PATH)/../../cocos2d/sqlite/*.c) LOCAL_SRC_FILES:=$(MY_CPP_LIST:$(LOCAL_PATH)/%=%) LOCAL_C_INCLUDES:=$(LOCAL_PATH)/../../Classes LOCAL_C_INCLUDES+=$(LOCAL_PATH)/../../cocos2d/sqlite
关键代码:
MY_CPP_LIST+=$(wildcard$(LOCAL_PATH)/../../cocos2d/sqlite/*.c)
LOCAL_C_INCLUDES+=$(LOCAL_PATH)/../../cocos2d/sqlite
感谢回头浪子的博文:http://blog.sina.com.cn/s/blog_6084f58801018i1v.html