Cocos2d v3 Out-Of-The-Box build 'Hello World' Bullet linker error [Ubuntu 16.10]

Hi all,

For the past week, I’ve been trying to get a vanilla build of Cocos2D-X without success. I’ve tried downloading from the official site as well as cloning from GitHub.

When building a vanilla project made with cocos new ..., I get the following output as a result of cocos run MyGame -p linux or simply make:

/usr/bin/ld: cocos2d/external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btBoxBoxDetector.o): relocation R_X86_64_32S against symbol `_ZTV16btBoxBoxDetector' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: cocos2d/external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btCompoundCollisionAlgorithm.o): relocation R_X86_64_32S against symbol `_ZTV28btCompoundCollisionAlgorithm' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: cocos2d/external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btCompoundCompoundCollisionAlgorithm.o): relocation R_X86_64_32S against symbol `_ZN36btCompoundCompoundCollisionAlgorithm22getAllContactManifoldsER20btAlignedObjectArrayIP20btPersistentManifoldE' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: cocos2d/external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btConvexConcaveCollisionAlgorithm.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: cocos2d/external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btConvexConvexAlgorithm.o): relocation R_X86_64_32S against symbol `_ZTV23btConvexConvexAlgorithm' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: cocos2d/external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btConvexPlaneCollisionAlgorithm.o): relocation R_X86_64_32S against symbol `_ZTV31btConvexPlaneCollisionAlgorithm' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: cocos2d/external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btHashedSimplePairCache.o): relocation R_X86_64_32S against symbol `_ZTV23btHashedSimplePairCache' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: cocos2d/external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btConcaveShape.o): relocation R_X86_64_32S against symbol `_ZTV14btConcaveShape' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: cocos2d/external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btPolyhedralConvexShape.o): relocation R_X86_64_32S against `.bss' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: cocos2d/external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btGjkEpa2.o): relocation R_X86_64_32 against symbol `_ZNK13btConvexShape31localGetSupportVertexNonVirtualERK9btVector3' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: cocos2d/external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btPolyhedralContactClipping.o): relocation R_X86_64_32S against symbol `_ZN15btStorageResult15addContactPointERK9btVector3S2_f' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: cocos2d/external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btConvexPolyhedron.o): relocation R_X86_64_32S against symbol `_ZTV18btConvexPolyhedron' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: cocos2d/external/bullet/prebuilt/linux/64-bit/libLinearMath.a(btAlignedAllocator.o): relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: cocos2d/external/bullet/prebuilt/linux/64-bit/libLinearMath.a(btConvexHullComputer.o): relocation R_X86_64_32 against symbol `__gxx_personality_v0@@CXXABI_1.3' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: cocos2d/external/bullet/prebuilt/linux/64-bit/libLinearMath.a(btQuickprof.o): relocation R_X86_64_32 against symbol `_ZN15CProfileManager4RootE' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output

The closest discussion I’ve found is this:

I managed to get the default hello world cpp example to build & link by running CMAKE GUI and unchecking the ‘USE BULLET’ checkbox.

Is this library just not functional in Linux? Should it be disabled?
I downloaded and built the bullet engine. It ran fine, but it builds an .so instead of a .a.

What can I do to make sure I can built right out of the box?
None of these guides have helped me solve the problem:

1 Like

What version of Cocos2d-x are you using?

I’m using v3.16, I believe.

This is from the v3 branch off GitHub.
At the time of writing, my current HEAD commit is: c66694cf20c3bde7d31f76e265c939685c96beb2

I should mention this is with a vanilla Ubuntu 16.10 image running on VirtualBox.

Did you run Linux-deps.py in bin/?