移植cocos2d-x 到ubuntu 12.04

      怎么移植网上很多教材,按部就班就OK,但在make过程中,出现了一个源码级问题:

../Classes/PerformanceTest/PerformanceAllocTest.cpp: 在成员函数‘virtual void NodeCreateTest::initWithQuantityOfNodes(unsigned int)’中:
../Classes/PerformanceTest/PerformanceAllocTest.cpp:256:49: 警告: 格式 ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘unsigned int’ [-Wformat]
../Classes/PerformanceTest/PerformanceAllocTest.cpp: 在成员函数‘virtual void NodeDeallocTest::initWithQuantityOfNodes(unsigned int)’中:
../Classes/PerformanceTest/PerformanceAllocTest.cpp:308:49: 警告: 格式 ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘unsigned int’ [-Wformat]
../Classes/PerformanceTest/PerformanceAllocTest.cpp: 在成员函数‘virtual void SpriteCreateEmptyTest::initWithQuantityOfNodes(unsigned int)’中:
../Classes/PerformanceTest/PerformanceAllocTest.cpp:365:51: 警告: 格式 ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘unsigned int’ [-Wformat]
../Classes/PerformanceTest/PerformanceAllocTest.cpp: 在成员函数‘virtual void SpriteCreateTest::initWithQuantityOfNodes(unsigned int)’中:
../Classes/PerformanceTest/PerformanceAllocTest.cpp:419:51: 警告: 格式 ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘unsigned int’ [-Wformat]
../Classes/PerformanceTest/PerformanceAllocTest.cpp: 在成员函数‘virtual void SpriteDeallocTest::initWithQuantityOfNodes(unsigned int)’中:
../Classes/PerformanceTest/PerformanceAllocTest.cpp:473:51: 警告: 格式 ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘unsigned int’ [-Wformat]


注意:由于我问题已经解决,没有保留bug现场,原问题是以上显示的'警告'是'错误',然后无法继续make,即输出make error

官方解决方案在此,如果官方解决方案仍无法解决问题,执行我的解决方案:

~/document/cocos2d-x-2.2.1/cocos2dx/proj.linux# cp cocos2dx.mk cocos2dx.mk.backup && vim cocos2dx.mk

注意:红色路径是源码中的具体目录,要修改的文件是去死去死团的cocos2dx.mk配置文件(修改前先备份),修改内容为:

 
 
CC = gcc
CXX = g++
CCFLAGS += -MMD -Wall -Werror -fPIC
CXXFLAGS += -MMD -Wall -Werror -fPIC

删除 -Werror ! 
更改后为:

CC = gcc
CXX = g++
CCFLAGS += -MMD -Wall -fPIC
CXXFLAGS += -MMD -Wall -fPIC


具体原因是,由于编译工具不同,在gcc/g++4.6以上的版本对弱格式转换提出警告,而-Werror的指令含义是将警告作为错误处理,warning变error,在我们不想降低gcc工具的版本时(想降低的都是爱将就的死人),可以去掉-Werror的选项。


你可能感兴趣的:(c,linux,ubuntu,移植,cocos2d-x)