在Linux上运行Cocos2d-x项目
Cocos2d-x在ubuntu上的开发环境搭建,请参考《Ubuntu18.04搭建Cocos2d开发环境》创建项目格式:$ cocos new MyGame -p com.your_company.mygame -l cpp -d NEW_PROJECTS_DIR实例:~/Desktop/Games$ cocos new OkGame -p com.wong.game -l cpp ...
·
Cocos2d-x在ubuntu上的开发环境搭建,请参考《Ubuntu18.04搭建Cocos2d开发环境》
创建项目
格式:
$ cocos new MyGame -p com.your_company.mygame -l cpp -d NEW_PROJECTS_DIR
实例:
~/Desktop/Games$ cocos new OkGame -p com.wong.game -l cpp -d game
结果:
~/Desktop/Games$ tree -L 2
.
├── game
│ └── OkGame
14 directories, 1 file
编译Cocos2d-x项目
- 运行cmake,生成makefile文件
/home/kyun/Desktop/Games/game/OkGame$ mkdir -p build/linux-build
/home/kyun/Desktop/Games/game/OkGame$ cd build/linux-build
/home/kyun/Desktop/Games/game/OkGame$ cmake ../..
- 当cmake结束后,/home/kyun/Desktop/Games/game/OkGame目录就会有相应生成的文件有目录:
~/Desktop/Games/game/OkGame/build/linux-build$ tree -L 1
.
├── bin
├── CMakeCache.txt
├── CMakeFiles
├── cmake_install.cmake
├── engine
├── lib
└── Makefile
4 directories, 3 files
- 运行make命令编译,编译时间会稍微长一点
~/Desktop/Games/game/OkGame/build/linux-build$ make -j 4
make编译完成后,所有的东西都会生成在 ~/Desktop/Games/game/OkGame/build/linux-build/bin目录里 :
~/Desktop/Games/game/OkGame/build/linux-build$ cd bin
~/Desktop/Games/game/OkGame/build/linux-build/bin$ tree -L 2.
└── OkGame
├── OkGame
└── Resources
2 directories, 1 file
- 运行
OkGame
游戏
~/Desktop/Games/game/OkGame/build/linux-build/bin$ ./OkGame/OkGame
Ready for GLSL
Ready for OpenGL 2.0
libpng warning: iCCP: known incorrect sRGB profile
运行效果如下:
以上就是在ubuntu18.04操作系统上,编译运行Cocos2d-x项目的全过程。
在运行以下命令时,可能会遇到异常信息:
~/Desktop/coco2dx/cocos2d-x-4.0/build/linux-build/bin/cpp-tests$ ./cpp-tests
异常信息:
./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》
谢谢阅读
更多推荐
已为社区贡献5条内容
所有评论(0)