在cocos2d-x中使用luajit(2)
来源:未知 责任编辑:责任编辑 发表时间:2014-01-25 11:31 点击:次
< -o $@
$(OBJ_DIR)/%.o: ../%.c $(CORE_MAKEFILE_LIST)
@mkdir -p $(@D)
$(LOG_CC)$(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@
显然对于linux来说,直接使用了lua而非luajit,既然我们要使用luajit,那么有两种选择,一种是将这里Makefile里的lua全部换成luajit,另外一种是将这个Makefile里的lua部分删除,将一个so文件分成两个。因为对luajit不是很熟悉,所以我们采用第二种。新的Makefile文件如下
但是这样一来就没有luajit了,怎么办呢?当然需要编译一个libluajit.so出来了,这个其实很简单,在${COCOS_ROOT}/scripting/lua/luajit/LuaJIT-2.0.1
显然对于linux来说,直接使用了lua而非luajit,既然我们要使用luajit,那么有两种选择,一种是将这里Makefile里的lua全部换成luajit,另外一种是将这个Makefile里的lua部分删除,将一个so文件分成两个。因为对luajit不是很熟悉,所以我们采用第二种。新的Makefile文件如下
TARGET = liblua.so INCLUDES += -I.. -I../luajit/include -I../tolua \ -I../Classes -I../../../CocosDenshion/include -I../../../extensions -I../../../external/chipmunk/include/chipmunk SOURCES = ../tolua/tolua_event.c \ ../tolua/tolua_is.c \ ../tolua/tolua_map.c \ ../tolua/tolua_push.c \ ../tolua/tolua_to.c \ ../cocos2dx_support/tolua_fix.c \ ../cocos2dx_support/CCLuaBridge.cpp \ ../cocos2dx_support/CCLuaEngine.cpp \ ../cocos2dx_support/CCLuaStack.cpp \ ../cocos2dx_support/CCLuaValue.cpp \ ../cocos2dx_support/Cocos2dxLuaLoader.cpp \ ../cocos2dx_support/LuaCocos2d.cpp \ ../cocos2dx_support/CCBProxy.cpp \ ../cocos2dx_support/Lua_extensions_CCB.cpp \ ../cocos2dx_support/lua_cocos2dx_extensions_manual.cpp include ../../../cocos2dx/proj.linux/cocos2dx.mk TARGET := $(LIB_DIR)/$(TARGET) SHAREDLIBS += -lextension all: $(TARGET) $(TARGET): $(OBJECTS) $(CORE_MAKEFILE_LIST) @mkdir -p $(@D) $(LOG_LINK)$(CXX) $(CXXFLAGS) $(OBJECTS) -shared -o $@ $(SHAREDLIBS) $(STATICLIBS) $(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) @mkdir -p $(@D) $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ $(OBJ_DIR)/%.o: ../%.c $(CORE_MAKEFILE_LIST) @mkdir -p $(@D) $(LOG_CC)$(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@
但是这样一来就没有luajit了,怎么办呢?当然需要编译一个libluajit.so出来了,这个其实很简单,在${COCOS_ROOT}/scripting/lua/luajit/LuaJIT-2.0.1
然后make就会在src下产生一下libluajit.so出来,只需要将这个文件拷贝到${COCOS_ROOT}/lib/linux/release以及${COCOS_ROOT}/lib/linux/debug下即可
到这里,其实已经将luajit准备好了,但是我们需要将工程里的Makefile文件进行一点小的修改,以${COCOS_ROOT}/samples/Lua/HelloLua为例
新的proj.linux/Makefile如下
EXECUTABLE = HelloLua COCOS_ROOT = ../../../.. INCLUDES = -I../ -I../Classes -I$(COCOS_ROOT)/CocosDenshion/include \ -I$(COCOS_ROOT)/scripting/lua/luajit/include \ -I$(COCOS_ROOT)/scripting/lua/tolua \ -I$(COCOS_ROOT)/scripting/lua/cocos2dx_support \ -I$(COCOS_ROOT)/extensions \ SOURCES = main.cpp ../Classes/AppDelegate.cpp SHAREDLIBS += -lcocos2d -lcocosdenshion -llua -lluajit -lextension COCOS_LIBS = $(LIB_DIR)/libcocos2d.so $(LIB_DIR)/libcocosdenshion.so $(LIB_DIR)/liblua.so $(LIB_DIR)/libluajit.so include $(COCOS_ROOT)/cocos2dx/proj.linux/cocos2dx.mk $(TARGET): $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST) @mkdir -p $(@D) $(LOG_LINK)$(CXX) $(CXXFLAGS) $(OBJECTS) -o $@ $(SHAREDLIBS) $(STATICLIBS) $(LIBS) $(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) @mkdir -p $(@D) $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>