Can't make Cocos2d-x compile on Ubuntu 18.04

I installed these dependencies as described here:

sudo apt-get install g++ libgdk-pixbuf2.0-dev python-pip cmake libx11-dev libxmu-dev libglu1-mesa-dev libgl2ps-dev libxi-dev libzip-dev libpng-dev libcurl4-gnutls-dev libfontconfig1-dev libsqlite3-dev libglew-dev libssl-dev libgtk-3-dev libglfw3 libglfw3-dev xorg-dev

In cocos2d-x-3.16/cocos/platform/desktop/CCGLViewImpl-desktop.h I had to change #include "glfw3.h" to #include "GLFW/glfw3.h"

And got this:

[ 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 PIE 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 PIE 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 PIE object; recompile with -fPIC /usr/bin/ld: ../../../../external/bullet/prebuilt/linux/64-bit/libBulletDynamics.a(btRigidBody.o): relocation R_X86_64_32S against symbol_ZN17btCollisionObject17setCollisionShapeEP16btCollisionShape’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: …/…/…/…/external/bullet/prebuilt/linux/64-bit/libBulletDynamics.a(btConeTwistConstraint.o): relocation R_X86_64_32S against symbol _ZTV21btConeTwistConstraint' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: ../../../../external/bullet/prebuilt/linux/64-bit/libBulletDynamics.a(btGeneric6DofConstraint.o): relocation R_X86_64_32S against symbol_ZTV23btGeneric6DofConstraint’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: …/…/…/…/external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btDbvtBroadphase.o): relocation R_X86_64_32S against symbol _ZTV16btDbvtBroadphase' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: ../../../../external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btOverlappingPairCache.o): relocation R_X86_64_32S against.rodata’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: …/…/…/…/external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btCollisionDispatcher.o): relocation R_X86_64_32S against symbol _ZTV23btCollisionPairCallback' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: ../../../../external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btCollisionObject.o): relocation R_X86_64_32S against symbol_ZTV17btCollisionObject’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: …/…/…/…/external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btCollisionWorld.o): relocation R_X86_64_32 against .rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: ../../../../external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btDefaultCollisionConfiguration.o): relocation R_X86_64_32S against symbol_ZTV31btDefaultCollisionConfiguration’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: …/…/…/…/external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btEmptyCollisionAlgorithm.o): relocation R_X86_64_32S against symbol _ZTV16btEmptyAlgorithm' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: ../../../../external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btGhostObject.o): relocation R_X86_64_32S against symbol_ZTV13btGhostObject’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: …/…/…/…/external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btManifoldResult.o): relocation R_X86_64_32S against symbol _ZTV16btManifoldResult' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: ../../../../external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btSimulationIslandManager.o): relocation R_X86_64_32S against symbol_ZTV25btSimulationIslandManager’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: …/…/…/…/external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btSphereSphereCollisionAlgorithm.o): relocation R_X86_64_32S against symbol _ZTV32btSphereSphereCollisionAlgorithm' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: ../../../../external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btSphereTriangleCollisionAlgorithm.o): relocation R_X86_64_32S against symbol_ZTV34btSphereTriangleCollisionAlgorithm’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: …/…/…/…/external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btUnionFind.o): relocation R_X86_64_32 against symbol __gxx_personality_v0@@CXXABI_1.3' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: ../../../../external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(SphereTriangleDetector.o): relocation R_X86_64_32S against symbol_ZTV22SphereTriangleDetector’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: …/…/…/…/external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btBvhTriangleMeshShape.o): relocation R_X86_64_32S against symbol _ZTV22btBvhTriangleMeshShape' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: ../../../../external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btCollisionShape.o): relocation R_X86_64_32S against symbol_ZNK16btCollisionShape17getBoundingSphereER9btVector3Rf’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: …/…/…/…/external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btConvexInternalShape.o): relocation R_X86_64_32S against symbol _ZNK21btConvexInternalShape9getMarginEv' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: ../../../../external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btConvexShape.o): relocation R_X86_64_32S against symbol_ZTV13btConvexShape’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: …/…/…/…/external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btOptimizedBvh.o): relocation R_X86_64_32S against symbol _ZTV14btOptimizedBvh' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: ../../../../external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btSphereShape.o): relocation R_X86_64_32S against symbol_ZNK13btSphereShape37localGetSupportingVertexWithoutMarginERK9btVector3’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: …/…/…/…/external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btTriangleMeshShape.o): relocation R_X86_64_32S against symbol _ZTV19btTriangleMeshShape' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: ../../../../external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btContinuousConvexCollision.o): relocation R_X86_64_32S against symbol_ZTV27btContinuousConvexCollision’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: …/…/…/…/external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btGjkConvexCast.o): relocation R_X86_64_32S against symbol _ZTV16btPointCollector' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: ../../../../external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btGjkPairDetector.o): relocation R_X86_64_32S against symbol_ZTV17btGjkPairDetector’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: …/…/…/…/external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btMinkowskiPenetrationDepthSolver.o): relocation R_X86_64_32 against .bss' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: ../../../../external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btRaycastCallback.o): relocation R_X86_64_32S against symbol_ZTV15btTriangleShape’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: …/…/…/…/external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btSubSimplexConvexCast.o): relocation R_X86_64_32S against symbol _ZTV22btSubsimplexConvexCast' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: ../../../../external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btVoronoiSimplexSolver.o): relocation R_X86_64_32S against.rodata’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: …/…/…/…/external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btCollisionAlgorithm.o): relocation R_X86_64_32S against symbol _ZTV20btCollisionAlgorithm' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: ../../../../external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btDbvt.o): relocation R_X86_64_32S against symbol_ZN6btDbvt6IClone9CloneLeafEP10btDbvtNode’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: …/…/…/…/external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btQuantizedBvh.o): relocation R_X86_64_32S against symbol _ZTV14btQuantizedBvh' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: ../../../../external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btActivatingCollisionAlgorithm.o): relocation R_X86_64_32S against symbol_ZTV30btActivatingCollisionAlgorithm’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: …/…/…/…/external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btBoxBoxCollisionAlgorithm.o): relocation R_X86_64_32S against symbol _ZTV26btBoxBoxCollisionAlgorithm' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: ../../../../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 PIE object; recompile with -fPIC
/usr/bin/ld: …/…/…/…/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 PIE object; recompile with -fPIC /usr/bin/ld: ../../../../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 PIE object; recompile with -fPIC
/usr/bin/ld: …/…/…/…/external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btConvexConcaveCollisionAlgorithm.o): relocation R_X86_64_32S against .rodata' can not be used when making a PIE object; recompile with -fPIC /usr/bin/ld: ../../../../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 PIE object; recompile with -fPIC
/usr/bin/ld: …/…/…/…/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 PIE object; recompile with -fPIC /usr/bin/ld: ../../../../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 PIE object; recompile with -fPIC
/usr/bin/ld: …/…/…/…/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 PIE object; recompile with -fPIC /usr/bin/ld: ../../../../external/bullet/prebuilt/linux/64-bit/libBulletCollision.a(btPolyhedralConvexShape.o): relocation R_X86_64_32S against.bss’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: …/…/…/…/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 PIE object; recompile with -fPIC /usr/bin/ld: ../../../../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 PIE object; recompile with -fPIC
/usr/bin/ld: …/…/…/…/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 PIE object; recompile with -fPIC /usr/bin/ld: ../../../../external/bullet/prebuilt/linux/64-bit/libLinearMath.a(btAlignedAllocator.o): relocation R_X86_64_32 against.text’ can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: …/…/…/…/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 PIE object; recompile with -fPIC /usr/bin/ld: ../../../../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 PIE object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
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

You don’t need to do this. I haven’t tried 18.04, it looks like it isn’t available yet… Only 17 and I am having a few issues with 16 getting installed on my Thinkpad. Prior to that I had used 14.x and 12.x.

18.04 will be released on April 26th. And it’s LTS release. But for a while there daily build available.
What issue with Thinkpad ?

I can never make it through the install process. It fails with very weird errors. I’ll try again now making sure I manually whack the disk. I’ll download a daily build and get it on a flash drive to try as well. Thank you for the link.

You also could try 16 on VirtualBox.

I have VMWare fusion on my Mac Pro, I am just not near it right now to try it. I have my Thinkpad on my couch here with me.

ok, I have 18.04 up and running, let me go through all the steps to see how I make out.

So far I just had to make one small change in the instructions to compile on 18.04.

I am compiling with make now but so far everything works according to what I have written.

I’d say this is a Virtual Box issue. We don’t do any testing inside of virtual machines. I am running on actual hardware.

What change ?

Just the package name of python.

I have a doc revisions to commit and the push to production to illustrate 16, 17, 18. I will do that now.

@Gdrop @slackmoehrle
Currently in travis we use trusty, It works in travis CI … but there are hacks which I do not understand. Please see files:
/tools/travis-scripts/before-install.sh
/tools/travis-scripts/run-script.sh
/build/install-deps-linux.sh

Travis support xenial (it is enough to add dist: xenial)
matrix:
include:
- os: linux
dist: xenial

I think that we should switch travis CI to xenial and update below scripts:
/tools/travis-scripts/before-install.sh
/tools/travis-scripts/run-script.sh
/build/install-deps-linux.sh
In that way that “steps in cocos2d-x doc” == “steps in travis CI scripts”

I looked at the steps before when you and I talked about this via a GitHub issue and I think there are so many travis-cl steps that are not needed, except for when using travis-cl. My goal was to try and make the Linux build process less complicated and easier for us to maintain as the latest distros are changing slightly with each release, package names, locations, dependencies, etc.

Why there:
Why there instructions to add older repos to 17.x and 18.x ?
First of all - it’s probably not safe to mess with packages for older release on a newer release.
And there no problems with finding any of those packages - no necessary to add ‘xenial main’.

Add a repo to /etc/apt/sources.list

```sh
deb http://cz.archive.ubuntu.com/ubuntu xenial main
```

And still don’t get about Python package - could you tell exactly where and what to change, thanks.

on 18, I am removing that line. it snuck in

on 17, it is required.

For python on 16 and 17 it is called python2.7 on 18 it is called python-minimal.

Here is the PR: https://github.com/cocos2d/cocos2d-x-docs/pull/142 and the docs are re-deploying to production. Usually takes 20 minutes.

I downloaded again through git, repeated steps form updated documentation and it went further, it seems everything gonna be alright this time.

Success. Thank you very much !!! :smiley:

1 Like

Absolutely. Let me know if you need anything else.

1 Like

excuse me. I’m new in here but this thread is related to my problem. I repeated steps from offical cocos gitbook (especialy for ubuntu 18.04). But i still get the same error at make -j 4 command. And the error is same as above this thread.

This looks like it isn’t installing all the deps…

hmm… what i’m missed for. i run install-deps-linux.sh and i got this. I’m sure i’ve installed libpng-dev. My ubuntu is 18.04.