首页 > 代码库 > linux上cocos2dx环境配置
linux上cocos2dx环境配置
1.cocos2dx 3.x开始要用到c++11,makefile文件中需要-std=c++11这个选项,
所以升级g++参考 http://www.cnblogs.com/coolulu/p/4124803.html
2.
l参考 | http://www.cocos2d-x.org/docs/manual/framework/native/v3/getting-started/how-to-run-cpp-tests-on-linux/en | ||
sudo apt-get install libx11-dev | |||
sudo apt-get install libxmu-dev | |||
sudo apt-get install libglu1-mesa-dev | |||
sudo apt-get install libgl2ps-dev | |||
sudo apt-get install libxi-dev | |||
sudo apt-get install g++ | |||
sudo apt-get install libzip-dev | |||
sudo apt-get install libpng12-dev | |||
sudo apt-get install libcurl4-gnutls-dev | |||
sudo apt-get install libfontconfig1-dev | |||
sudo apt-get install libsqlite3-dev | |||
sudo apt-get install libglew*-dev | |||
sudo apt-get install libssl-dev | |||
$ cd $cocos2dx_root/build | |||
$ ./install-deps-linux.sh | |||
$ mkdir linux-build | |||
$ cd linux-build | |||
$ cmake ../.. | |||
$ make(建议make -k遇到错误不中断,继续编译,节省时间) | |||
问题1 解决 | cocos2dx3.x 生成makefile g++需要支持-std=c++11编译选项 把g++升级到4.8.3 | ||
问题2 解决 | Linking CXX executable ../../bin/cpp-empty-test/cpp-empty-test | ||
/usr/bin/ld: cannot find -lfmodex64 | |||
/usr/bin/ld: cannot find -lwebsockets | |||
/usr/bin/ld: cannot find -ljpeg | sudo apt-get install libjpeg-dev | ||
/usr/bin/ld: cannot find -lwebp | sudo apt-get install libwebp-dev | ||
/usr/bin/ld: cannot find -ltiff | sudo apt-get install libtiff4-dev | ||
collect2: 错误:ld 返回 1 | |||
make[2]: *** [bin/cpp-empty-test/cpp-empty-test] Error 1 | |||
make[1]: *** [tests/cpp-empty-test/CMakeFiles/cpp-empty-test.dir/all] Error 2 | |||
make: *** [all] Error 2 | |||
问题3 解决 | /usr/bin/ld: cannot find -lfmodex64 | ||
FQ | 参考:http://ubuntuguide.org/wiki/Skulltag_tips | ||
FQ | 参考:http://wiki.zandronum.com/Install_Zandronum_on_Ubuntu | ||
wget -c http://www.fmod.org/download/fmodex/api/Linux/fmodapi42416linux64.tar.gz | |||
make install | |||
mv /usr/local/lib/libfmodex64-4.24.16.so /usr/local/lib/libfmodex64.so | |||
问题4 解决 | /usr/bin/ld: cannot find -lwebsockets | ||
wget -c http://git.libwebsockets.org/cgi-bin/cgit/libwebsockets/snapshot/libwebsockets-1.3-chrome37-firefox30.tar.gz | |||
先要安装openssl | |||
sudo apt-get install openssl | |||
sudo apt-get install libssl-dev | |||
cd 源代码目录 | |||
mkdir build | |||
cd build | |||
cmake .. | |||
make | |||
cd lib | |||
vi /etc/ld.so.conf 添加/usr/local/lib ldconfig | |||
1 | cp libwebsockets.so.4.0.0 /usr/local/lib/libwebsockets.so 这个方法后报 问题5 | ||
问题5 解决 | Linking CXX executable ../../bin/cpp-empty-test/cpp-empty-test | ||
../../lib/libcocos2d.a(CCImage.cpp.o): In function `WebPIDecGetYUV‘: | |||
/home/melos1305/project/cocos2dx/cocos2d-x-3.1/external/webp/include/linux/decode.h:322: undefined reference to `WebPIDecGetYUVA‘ | |||
collect2: 错误:ld 返回 1 | |||
make[2]: *** [bin/cpp-empty-test/cpp-empty-test] Error 1 | |||
make[2]: Target `tests/cpp-empty-test/CMakeFiles/cpp-empty-test.dir/build‘ not remade because of errors. | |||
make[1]: *** [tests/cpp-empty-test/CMakeFiles/cpp-empty-test.dir/all] Error 2 | |||
[ 72%] Built target cpp-empty-test_CORE_PRE_BUILD | |||
cpp-empty-test_PRE_BUILD ... | |||
可能是sudo apt-get install libwebp-dev安装的版本对不上,sudo apt-get remove libwebp-dev | |||
后面自然好,在/external/webp/prebuilt/linux/64-bit/libwebp.a 转换成 libweb.so ar -x libwebp.a;gcc -shared *.o -o libwebp.so | |||
一开始还是错的, mv libwebp.so libwebp.so111 删了libwebp.so编译过了 | |||
计划去下载webp":"0.2.1的源代码编译 | |||
wget -c https://chromium.googlesource.com/webm/libwebp/+archive/74fefc8ce8d83946b763345575d6d2c608ba212a.tar.gz | |||
问题6 解决 | melos1305@melos1305-B85M-DS3H:~/project/cocos2dx/cocos2d-x-3.1/build/linux-build/bin/cpp-empty-test$ ./cpp-empty-test | ||
./cpp-empty-test: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.18‘ not found (required by ./cpp-empty-test) | |||
1. vi /etc/ld.so.conf 添加/usr/local/gcc-4.8.3/lib64/libstdc++.so.6 ldconfig 失败 | |||
2. ln -si /usr/local/gcc-4.8.3/lib64/libstdc++.so.6.0.19 libstdc++.so.6 | |||
ok 只能挂链接,服务端的ubuntu是64位,所以lib64/libstd++.so.6的默认版本不够,需要支持到GLIBCXX_3.4.18以上, | |||
查看GLIBCXX信息 strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX | |||
strings /usr/local/gcc-4.8.3/lib64/libstdc++.so.6.0.19 | grep GLIBCXX |
编译完之后执行文件在cocos2d-x-3.1/build/linux-build/bin的子文件夹里
3. 上面的找不到库文件的问题是,其实可以不用自己找,被坑了。
因为svn服务器上默认不上传.a文件。类似的还有可能是.so文件。比如如果用了fmod库,提示找不到fmod库的.so文件的时候,
看看svn设置里面的忽略文件类型。一般*.a和*.so都是被忽略的。任意文件夹右击,找到tortoiseSVN->属性(setting)->常规属性,右侧面板下方可看到。
参考 http://blog.csdn.net/o_oxo_o/article/details/39377797
参考 http://blog.csdn.net/lxd211/article/details/23977525
linux上cocos2dx环境配置
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。