0

I'm trying to compile Cocos2d-x on Ubuntu 17.10. But after I run make I'm getting this:

[ 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

In /usr/local/lib I have only these files:

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

Where to get those .a files?

Tsyvarev
  • 60,011
  • 17
  • 110
  • 153
Andy D
  • 125
  • 13
  • Possible duplicate of ["relocation R\_X86\_64\_32S against " linking Error](https://stackoverflow.com/questions/19768267/relocation-r-x86-64-32s-against-linking-error) – Tsyvarev Mar 11 '18 at 18:10
  • Also, formatting the code in the post is achieved simply by pressing `Ctrl+K` or `{}` button with the code selected. No needs to manually insert `
    ` or other line breaks.
    – Tsyvarev Mar 11 '18 at 18:11
  • @Tsyvarev may be, but no solution there for me. When I use `{}` then it not formatted as I want - many lines gonna be on one. – Andy D Mar 11 '18 at 18:21
  • @Tsyvarev where to get those .a files ? – Andy D Mar 11 '18 at 20:38
  • The error is about `libBulletDynamics.a` library, which is shipped with cocos2d sources. Probably, you need to report this incompatibility problem to developers. – Tsyvarev Mar 11 '18 at 20:55

1 Answers1

0

I don't know if you have solved your issue, but this might be useful to others:

This is a very common issue as cocos2d-x ships prebuilt librairies to reduce compilation time. However some of them don't work on "newer" distros. So it doesn't work on Ubuntu 17, and Arch for example.

There are two solutions to this:

  • If you don't need libBullet for your project, you can simply tell CMake not to use it. It's an easy and effortless fix. To do this I recommeend this:

    cd project_root
    mkdir build
    cd build
    cmake ..
    ccmake .
    

    Once ccmake is launched, you can set the USE_BULLET option to OFF, and press c to configure the project again. Then you're good to go, you can compile.

  • If you however need libBullet, you will need to recompile it to generate a valid .a file. I suggest you have a look at the corresponding cocos2d repo.

Gaëtan B
  • 1
  • 1