不能在Ubuntu 17.10上制作Cocos 2d-x

时间:2018-03-11 17:37:32

标签: cmake cocos2d-x

我正在尝试在Ubuntu 17.10上编译Cocos2d-x。 但在我运行make后,我得到了这个:

[ 68%] Built target cocos2d
[ 68%] Linking CXX executable …/…/bin/cpp-empty-test/cpp-empty-test
/usr/bin/ld: …/…/…/…/external/bullet/prebuilt/linux/64-bit/libBulletDynamics.a(btSequentialImpulseConstraintSolver.o): relocation R_X86_64_32 against .rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: ../../../../external/bullet/prebuilt/linux/64-bit/libBulletDynamics.a(btTypedConstraint.o): relocation R_X86_64_32S against symbol_ZTV17btTypedConstraint’ can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: …/…/…/…/external/bullet/prebuilt/linux/64-bit/libBulletDynamics.a(btDiscreteDynamicsWorld.o): relocation R_X86_64_32 against `.rodata.str1.1’ can not be used when making a shared object; recompile with -fPIC

…

tests/cpp-empty-test/CMakeFiles/cpp-empty-test.dir/build.make:174: recipe for target 'bin/cpp-empty-test/cpp-empty-test' failed
make[2]: *** [bin/cpp-empty-test/cpp-empty-test] Error 1
CMakeFiles/Makefile2:466: recipe for target 'tests/cpp-empty-test/CMakeFiles/cpp-empty-test.dir/all' failed
make[1]: *** [tests/cpp-empty-test/CMakeFiles/cpp-empty-test.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

/usr/local/lib我只有这些文件:

cmake          libavfilter.a  libglfw.so      libswresample.a  pkgconfig
libavcodec.a   libavformat.a  libglfw.so.3    libswscale.a     python2.7
libavdevice.a  libavutil.a    libglfw.so.3.2  node_modules     python3.6

从哪里获取这些.a个文件?

1 个答案:

答案 0 :(得分:0)

我不知道你是否解决了你的问题,但这可能对其他人有用:

这是一个非常常见的问题,因为cocos2d-x提供了预建的库,以减少编译时间。然而,其中一些不适用于“较新”的发行版。因此它不适用于Ubuntu 17和Arch。例如。

有两种解决方案:

  • 如果你的项目不需要libBullet,你可以告诉CMake不要使用它。这是一个简单而轻松的修复。要做到这一点,我建议这样做:

    cd project_root
    mkdir build
    cd build
    cmake ..
    ccmake .
    

    启动ccmake后,您可以将USE_BULLET选项设置为OFF,然后按c再次配置项目。然后你很高兴,你可以编译。

  • 如果您需要libBullet,则需要重新编译它以生成有效的.a文件。我建议您查看corresponding cocos2d repo