cocos2d-x 导入lua扩展库有几个点需要注意:
1、cocos2d-x 中的lua版本为5.1.4,所导入的lua库需要对应相应的版本库。
2、在vs 2012 中编译cocos2d-x ,添加的C文件需要注明用C编译,如一般.h文件需要这样写
#ifndef __LUA_LPEG_H_
#define __LUA_LPEG_H_
#if __cplusplus
extern "C" {
#endif
#include "lua.h"
#include "lauxlib.h"
int luaopen_lpeg(lua_State *L);
#if __cplusplus
}
#endif
//int luaopen_lpeg(lua_State *L);
#endif
3、在cocos2d-x 中lua_extensions 中需要为添加相应头文件,相对应的lua库注册,在static luaL_Reg luax_exts[] 中添加需要添加的代码 {"lpeg",luaopen_lpeg}。
4、android 支持,在Android.mk中添加 增加的文件。