• cocos2dx linux本地环境搭建


    ===12.01更新===

    每次都要真机调试特别麻烦,

    所以今天搭建了半天的linux本地环境

    原来我的版本是2.1.2rc运行make-linux-project的时候失败,莫名其妙

    里面的DEPENDS变量无法遍历什么的。。

    好吧仔细看了sh文件和查了官网资料以后发现可以直接make嘛。。

    现实遇到了一个node节点的数组初始化的长度过小的问题。找到了源码然后在初始化的时候直接把最大长度从6改到了100就编译通过了

    不过又有问题了。在sample下的TestCpp总是报错。问题貌似和openGL还是openES的调用有关

    (抱歉我也不知道GL和ES的区别是什么待会百度一下)

    不过还好这只是一个例子程序而已不影响大问题

    后来使用make -i命令ignore掉了错误

    犯傻找不到编译生成的文件在哪里了= =

    于是又死马当做活马医的去官网下了个2.2.1版本。不过这个版本就更加奇怪了。

    这里是make 命令之后的结果

    ../Classes/PerformanceTest/PerformanceAllocTest.cpp: In member function ‘virtual void NodeCreateTest::initWithQuantityOfNodes(unsigned int)’:
    ../Classes/PerformanceTest/PerformanceAllocTest.cpp:256:49: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘unsigned int’ [-Werror=format=]
         printf("Size of Node: %lu
    ", sizeof(CCNode));
                                                     ^
    ../Classes/PerformanceTest/PerformanceAllocTest.cpp: In member function ‘virtual void NodeDeallocTest::initWithQuantityOfNodes(unsigned int)’:
    ../Classes/PerformanceTest/PerformanceAllocTest.cpp:308:49: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘unsigned int’ [-Werror=format=]
         printf("Size of Node: %lu
    ", sizeof(CCNode));
                                                     ^
    ../Classes/PerformanceTest/PerformanceAllocTest.cpp: In member function ‘virtual void SpriteCreateEmptyTest::initWithQuantityOfNodes(unsigned int)’:
    ../Classes/PerformanceTest/PerformanceAllocTest.cpp:365:51: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘unsigned int’ [-Werror=format=]
         printf("Size of Node: %lu
    ", sizeof(CCSprite));
                                                       ^
    ../Classes/PerformanceTest/PerformanceAllocTest.cpp: In member function ‘virtual void SpriteCreateTest::initWithQuantityOfNodes(unsigned int)’:
    ../Classes/PerformanceTest/PerformanceAllocTest.cpp:419:51: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘unsigned int’ [-Werror=format=]
         printf("Size of Node: %lu
    ", sizeof(CCSprite));
                                                       ^
    ../Classes/PerformanceTest/PerformanceAllocTest.cpp: In member function ‘virtual void SpriteDeallocTest::initWithQuantityOfNodes(unsigned int)’:
    ../Classes/PerformanceTest/PerformanceAllocTest.cpp:473:51: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘unsigned int’ [-Werror=format=]
         printf("Size of Node: %lu
    ", sizeof(CCSprite));
                                                       ^
    cc1plus: all warnings being treated as errors

    大概报错的意思是在printf函数里面的使用了%lu的占位符来进行输出但是sizeof命令输出的其实是unsigned int所以报出了warning

    但是所有warning都会被看成error所有错误了无法成功编译

    百度了一下,是在GCC命令后面添加了-Werror命令所以失败,于是从Makefile慢慢开始溯源,

    最终在./cocos2dx/proj.linux/cocos2dx.mk文件里面找到了这个参数

    all:
    
    CC = gcc
    CXX = g++
    CCFLAGS += -MMD -Wall -Werror -fPIC
    CXXFLAGS += -MMD -Wall -Werror -fPIC
    ARFLAGS = cr
    
    DEFINES += -DLINUX

    不过很奇妙的是就算删除了这个参数也无法make成功= =

    求大神指点可能是我的系统太奇葩还是我该多扶扶老奶奶了。

    同时也尝试过吧源码里面的%lu占位符修改为%u同样失败恩

    就在绝望的时候灵感突然一现然后在原来的2.1.2rc版的

    ./samples/Cpp/HelloCpp/proj.linux/bin/release目录下有已经编译好的HelloCpp可执行文件了。。。。。

    瞎折腾真是。。

    ====

    12,01 21:11分

    卧槽!!!!!

    在写这篇文章的时候改了2.2.1的cocos2dx.mk之后又编译通过了尼玛!!!!!!!!!!!

    不过出现了新的错误!

    CXX obj/release/Classes/VisibleRect.o
     CXX obj/release/main.o
     LINK bin/release/TestCpp
    /usr/bin/ld: /home/pipicold/cocos2d/cocos2d-x-2.2.1/cocos2d-x-2.2.1/lib/linux/release/libextension.a(HttpClient.o): undefined reference to symbol 'pthread_create@@GLIBC_2.1'
    /lib/i386-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
    collect2: error: ld returned 1 exit status
    make[1]: *** [bin/release/TestCpp] 错误 1
    make[1]:正在离开目录 `/home/pipicold/cocos2d/cocos2d-x-2.2.1/cocos2d-x-2.2.1/samples/Cpp/TestCpp/proj.linux'
    make: *** [all] 错误 2

    应该是HttpClient部分的源码有错误。。未定义?

    总之现在用不着暂时反正从路径来看应该是个例子程序或者测试程序!所以ignore!!!

     $sudo make -j10 -i

    ye!ok done~~~~~~

    撒花~~~~~

    ==============

  • 相关阅读:
    mysql binlog日志
    安装源码包(这里主要写了redis,其他都一样的操作)
    hashMap异常:java.util.ConcurrentModificationException
    谷歌post url “net::ERR_INCOMPLETE_CHUNKED_ENCODING”
    itextpdf结合jfinal模版生成pdf文件
    springboot项目jar冲突问题解决
    map遍历
    el和jstl表达式问题==0的问题
    fastJSON 解析转换包含下划线属性的问题
    CentOS 7 64位
  • 原文地址:https://www.cnblogs.com/pipicold/p/3452962.html
Copyright © 2020-2023  润新知