1. 安装最新版的cmake, 编译cocos2d-x需要
-- yum -y install cmake 通过yum安装的版本 有些参数还是认不到, 这个还是直接下载安装 3.x版本吧,
wget tar zxvf cmake-3.3.2.tar.gz
cd cmake-3.3.2
./configure --prefix=/usr/local
make -j4
make install
2. cocos依赖库
下列大部分都可以直接 yum -y install 来安装, 需要源码的会有注释
libX11 libX11-devel
libXrandr libXrandr-devel
libXxf86vm libXxf86vm-devel
libXmu libXmu-devel
libXi libXi-devel
libzip libzip-devel
-- libcurl-devel 系统安装的是 libcurl-7.19.7-46.el6.x86_64, 这个需要安装 >= 7.21.6 版本的,不然会出现error: ‘CURLOPT_ACCEPT_ENCODING’ was not declared in this scope
sqlite sqlite-devel
openssl-devel
mesa-libGL
mesa-libGLU mesa-libGLU-devel
mesa-libGL-devel --> opengl
-- glew-devel
系统安装的是 glew-1.5.5-1.el6.x86_64, 这个需要比较新的版本1.13.0 ,不然会出错:jsb_opengl_functions.cpp:326:35: error: ‘glClearDepthf’ was not declared in this scope
fontconfig-devel
libpng-devel
glfw --> 详见下面 glfw依赖项
3. libcurl 安装
可以先把系统的卸载了 yum remove libcurl-devel
tar jxvf curl-7.45.0.tar.bz2
cd curl-7.45.0
./configure --prefix=/usr
make
make install
4. 源码安装 glew
glew-1.13.0.tgz
make
make install
5. 修改CMakeLists
编辑 cocos2d-x-3.7/cocos/base/CMakeLists.txt
添加 base/CCInjector.cpp
在cocos/ui/CMakeLists.txt 中添加:
ui/UIScrollViewBar.cpp
6. link chipmunk 出错
undefined reference to `__pow_finite'
... ...
按网页说的 加了-m选项,依然无效
手动下载安装 Chipmunk 6.2.1
cmake .
会出错 :
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
GLFW_INCLUDE_DIR
used as include directory in directory /root/cocos/depends/Chipmunk2D-6.2.x/Demo
GLFW_LIBRARIES
linked by target "chipmunk_demos" in directory /root/cocos/depends/Chipmunk2D-6.2.x/Demo
Chipmunk 6.x 只能用glfw 3.0以前的版本,所以这里还需要下载个2.x的glfw 来编译一把
然后cmake .
make
链接出错, 在src/CMakeLists.txt 加上
在 BUILD_SHARED 区间加上
target_link_libraries(chipmunk Xrandr)
在 BUILD_STATIC 区间加上
target_link_libraries(chipmunk_static Xrandr)
make install
我们只要个 libchipmunk.a 就够了
拷贝到 cocos2d-x-3.7/external/chipmunk/prebuilt/linux/64-bit 目录下, 把cocos自带的给备份下。
7. glfw 依赖项
yum -y install libXrandr-devel libXinerama-devel
yum -y install libXcursor-devel
unzip glfw-3.1.2.zip
cd glfw-3.1.2
cmake -G "Unix Makefiles"
make
这一步会出错,
|
It's a pretty bad solution, as I haven't really got a chance to understand why this happened, but I removed all references to the docs in CMakeList.txt. So anything that is declared in the
if (GLFW_BUILD_DOCS)
endif()
statement, I removed.
And then it seems to work. I really don't understand why turning documentation off doesn't work, but I'd need to spend more time looking at the way the CMakeList file is built.
This then, is a quick and dirty solution.
|
也可以通过把doxygen 从1.6 升级到 1.8.10 解决
make install
8. 编译cocos2d-x
export CC=/usr/local/bin/gcc
export CXX=/usr/local/bin/g++
cd linux-build/
cmake -G "Unix Makefiles" -DBUILD_CPP_TESTS=OFF -DBUILD_LUA_LIBS=OFF ..
编译过程会找不到freetype.h 然后 将cocos2d-x-3.7/external/freetype2/include/linux/freetype 文件夹里面的文件上移一层即可找到了
链接会找不到 x11_init.c:(.text+0x1beb): undefined reference to `XIQueryVersion' 需要link -lXi
tests/js-tests/project/CMakeLists.txt 文件的 target_link_libraries 里面加上 Xi
make
终于成功了!!!
9. 编译好的库在链接jpeg的时候 会出错,需要下载新版本的libjpeg, 编译
详见里面的 build.txt
阅读(3394) | 评论(0) | 转发(0) |