在Linux上运行Cocos2d-x安装目录中的示例游戏
Cocos2d-x在ubuntu上的开发环境搭建,请参考《Ubuntu18.04搭建Cocos2d开发环境》
我的Cocos2d-x的安装目录在:/home/kyun/Desktop/coco2dx/cocos2d-x-4.0:
示例代码所在位置:/home/kyun/Desktop/coco2dx/cocos2d-x-4.0/tests:
编译Cocos2d-x安装目录下的示例代码
- 运行cmake,生成makefile文件
~$ cd /home/kyun/Desktop/coco2dx/cocos2d-x-4.0
~/Desktop/coco2dx/cocos2d-x-4.0$ mkdir -p build/linux-build
~/Desktop/coco2dx/cocos2d-x-4.0$ cd build/linux-build
~/Desktop/coco2dx/cocos2d-x-4.0/build/linux-build$ cmake ../..
- 1
- 2
- 3
- 4
- 当cmake结束后,~/Desktop/coco2dx/cocos2d-x-4.0/build/linux-build目录就会有相应生成的文件有目录:
~/Desktop/coco2dx/cocos2d-x-4.0/build/linux-build$ tree -L 1.
├── bin
├── CMakeCache.txt
├── CMakeFiles
├── cmake_install.cmake
├── engine
├── lib
└── Makefile
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 运行make命令编译,编译时间会稍微长一点
~/Desktop/coco2dx/cocos2d-x-4.0/build/linux-build$ make -j 4
- 1
make编译完成后,所有的东西都会生成在 ~/Desktop/coco2dx/cocos2d-x-4.0/build/linux-build/bin目录里 :
~/Desktop/coco2dx/cocos2d-x-4.0/build/linux-build$ cd bin
~/Desktop/coco2dx/cocos2d-x-4.0/build/linux-build/bin$ tree -L 1
.
├── cpp-empty-test
├── cpp-tests
├── HelloCpp
├── lua-empty-test
└── lua-tests
5 directories, 0 files
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 运行
cpp-tests
项目
~/Desktop/coco2dx/cocos2d-x-4.0/build/linux-build$ cd bin/cpp-tests
~/Desktop/coco2dx/cocos2d-x-4.0/build/linux-build/bin/cpp-tests$ ./cpp-tests
Ready for GLSL
Ready for OpenGL 2.0
Console: IPV4 server is listening on 0.0.0.0:5678
- 1
- 2
- 3
- 4
- 5
- 6
- 7
以上就是在ubuntu18.04操作系统上,编译运行Cocos2d-x-4.0安装目录下的示例游戏的全过程。
在运行
~/Desktop/coco2dx/cocos2d-x-4.0/build/linux-build/bin/cpp-tests$ ./cpp-tests
- 1
你可能会遇到以下异常:
./cpp-tests: error while loading shared libraries: /home/kyun/Desktop/coco2dx/cocos2d-x-4.0/external/linux-specific/fmod/prebuilt/64-bit/libfmod.so.6: file too short
请参考《Cocos2d-x异常external/linux-specific/fmod/prebuilt/64-bit/libfmod.so.6: file too short》
谢谢阅读
文章来源: blog.csdn.net,作者:WongKyunban,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/weixin_40763897/article/details/104898215
- 点赞
- 收藏
- 关注作者
评论(0)