Can't make Cocos 2d-x on Ubuntu 17.10

After I run ‘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

What is your toolchain? What Cocos2d-x version?

Cocos 2d-x 3.16

Not sure what is toolchain and how to get it.
This may be: gcc version 7.2.0 (Ubuntu 7.2.0-8ubuntu3.2) ?

are you following this: http://www.cocos2d-x.org/docs/cocos2d-x/en/installation/Linux.html

Yes I do. I installed dependencies by ./install-deps-linux.sh.
But I had to install also these manually:

    sudo apt-get install glew-utils libglew-dev
    sudo apt-get install sqlite3 libsqlite3-dev
    sudo apt-get install libgtk-3-dev
    sudo apt-get install libcurl4-openssl-dev

are you running 32-bit or 64-bit Ubuntu?

64-bit Ubuntu.

I see, this might be the problem

/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

I have an ubuntu 17.10 laptop, let me take a look

Ok, I’ll wait.

I’m starting to work on this this afternoon.

I had similar problem. Calling $COCOS2DX_ROOT/build/install-deps-linux.sh is not enough

Please check function install_linux_environment() from travis CI script and repeat all steps.

Comments:

  1. I think that step in docs and in travis CI should be exactly the same (only in that way we can be sure that it really works)
  2. Could any one explain why we needs all those lines in https://github.com/cocos2d/cocos2d-x/blob/v3/tools/travis-scripts/before-install.sh

function install_linux_environment()
{
mkdir -p $HOME/bin
pushd $HOME/bin
echo "GCC version: gcc --version"
# install new version cmake
CMAKE_VERSION=“3.7.2”
CMAKE_DOWNLOAD_URL=“https://cmake.org/files/v3.7/cmake-${CMAKE_VERSION}.tar.gz
echo “Download ${CMAKE_DOWNLOAD_URL}”
curl -O ${CMAKE_DOWNLOAD_URL}
tar -zxf “cmake-${CMAKE_VERSION}.tar.gz”
cd “cmake-${CMAKE_VERSION}”
./configure > /dev/null
make -j2 > /dev/null
sudo make install > /dev/null
echo "CMake Version: cmake --version"
cd …
# install new version binutils
BINUTILS_VERSION=“2.27”
BINUTILS_URL=“http://ftp.gnu.org/gnu/binutils/binutils-${BINUTILS_VERSION}.tar.gz
echo “Download ${BINUTILS_URL}”
curl -O ${BINUTILS_URL}
tar -zxf “binutils-${BINUTILS_VERSION}.tar.gz”
cd “binutils-${BINUTILS_VERSION}”
./configure > /dev/null
make -j2 > /dev/null
sudo make install > /dev/null
echo "ld Version: ld --version"
echo "which ld: which ld"
sudo rm /usr/bin/ld
popd
echo “Installing linux dependence packages …”
echo -e “y” | bash $COCOS2DX_ROOT/build/install-deps-linux.sh
echo “Installing linux dependence packages finished!”
}
3. build/install-deps-linux.sh should be update currently there is g+±4.9
4. For future all external Linux dependencies should be delivered as for other platforms (by download-deps.py).

@CrazyHappyGame you are saying you had to execute everything in that function to get Cocos2d-x working on Linux?

Yes.

Comment:
Please update install_linux_environment if it is not true.
When I called only $COCOS2DX_ROOT/build/install-deps-linux.sh I had:
/usr/bin/ld: ../cocos2d/external/bullet/prebuilt/linux/64-bit/libBulletDynamics.a(btConeTwistConstraint.o): unrecognized relocation (0x2a) in section.text’`

error on:

I am testing this now, starting with a fresh clone of the repo.

There is chance that it will work for you (e.g. if you already built before cocos2d-x on that laptop :slight_smile: )
Please check it on clean ubuntu instance ( or VM, docker, travis CI image).

This is a clean laptop that I just loaded up this weekend :slight_smile: Dont worry.

Edit 1: so far installing deps fails, it doesn’t find any of them. I need to see where these are located now.

Edit 2: actually the packages exist, just the script is failing. Installing them manually is working. libpng12-dev and libglew*-dev aren’t found. I need to see what to do here.

Edit 3: OK, I worked through these, now to try the next steps

Edit 4: worked through glfw issues.

Edit 5: Did anyone run ./download-deps.py?

Edit 6: It has been a manual effort, but make is running now. So far no errors.

I tried to run download-deps.py now and nothing changes:

    $ python download-deps.py
    =======================================================
    ==> Prepare to download external libraries!
    ==> Not need to update!

I will continue this in a few hours and report back at how I am doing. Last night before bed make had been running for almost an hour.

ok, so it was a manual effort, but I compiled successfully on 17.10 We should probably try and update this doc with more manual steps and also fix issues with install-linux-deps.py

May be better to engage with Ubuntu 18.04 ? (It will be ready this April, but beta is usable, I only had to download some packages using another system to get working “pppoe” (DSL) connection to Internet.) There problem too.