Linux Fedora 29 + Android Studio 3.3 + Cocos 3.17.1 fresh project doesn't compile

I installed a new PC with Fedora 29, java 1.8.0_201 (from Oracle), Android Studio 3.3, cocos 3.17.1

I created a new project using
cocos new -d . -p net.comtor.games.test1 -l cpp Test

I opened it using android studio (Test/proj.android)
When I tried to compile it the result is:

Cause: executing external native build for cmake /home/juriel/cocos/Test1/CMakeLists.txt

or

SIMPLE: Error configuring

When I opened gradle.properties android studios shows "Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly.

How did you get cocos2d-x? GitHub or our .zip?

Did you follow our install instructions? We don’t specifically test on Fedora however.

I installed cocos2d-x from .zip from cocos2d-x web page.

I’m not sure what the official installation tutorial is. But I installed serveral packages using dnf
dnf install gcc-c++
dnf install fontconfig-devel
dnf install gtk3-devel
dnf install cmake
dnf install python2-pip
dnf install libgdk-pixbuf2.0-dev
dnf install libzip-devel
dnf install -y libssl-dev libxmu-dev libpng-dev

Because android studio reports problems with cmake I ran de command manually. It reported need some libraries and I installed it. This is the latest

[juriel@localhost Test6]$ cmake /home/juriel/cocos/Test6/CMakeLists.txt
– PROJECT_NAME:Test6
– PROJECT_SOURCE_DIR:/home/juriel/cocos/Test6
– COCOS2DX_ROOT_PATH:/home/juriel/cocos/Test6/cocos2d
– CMAKE_MODULE_PATH:/home/juriel/cocos/Test6/cocos2d/cmake/Modules/
– PROJECT_BINARY_DIR:/home/juriel/cocos/Test6
– ENGINE_BINARY_PATH:/home/juriel/cocos/Test6/engine
– CMAKE_BUILD_TYPE: Debug
– Fontconfig include dirs: /usr/include/freetype2;/usr/include/libpng16;/usr/include/uuid
– GTK3 include dirs: /usr/include/gtk-3.0;/usr/include/pango-1.0;/usr/include/glib-2.0;/usr/lib64/glib-2.0/include;/usr/include/fribidi;/usr/include/cairo;/usr/include/pixman-1;/usr/include/freetype2;/usr/include/libpng16;/usr/include/uuid;/usr/include/harfbuzz;/usr/include/gdk-pixbuf-2.0;/usr/include/libmount;/usr/include/blkid;/usr/include/gio-unix-2.0/;/usr/include/libdrm;/usr/include/atk-1.0;/usr/include/at-spi2-atk/2.0;/usr/include/at-spi-2.0;/usr/include/dbus-1.0;/usr/lib64/dbus-1.0/include
– ZLIB include dirs: /usr/include
– PNG include dirs: /usr/include;/usr/include
– GLEW include dirs: /usr/include
CMake Warning (dev) at /usr/share/cmake/Modules/FindOpenGL.cmake:270 (message):
Policy CMP0072 is not set: FindOpenGL prefers GLVND by default when
available. Run “cmake --help-policy CMP0072” for policy details. Use the
cmake_policy command to set the policy and suppress this warning.

FindOpenGL found both a legacy GL library:

OPENGL_gl_LIBRARY: /usr/lib64/libGL.so

and GLVND libraries for OpenGL and GLX:

OPENGL_opengl_LIBRARY: /usr/lib64/libOpenGL.so
OPENGL_glx_LIBRARY: /usr/lib64/libGLX.so

OpenGL_GL_PREFERENCE has not been set to “GLVND” or “LEGACY”, so for
compatibility with CMake 3.10 and below the legacy GL library will be used.
Call Stack (most recent call first):
cocos2d/cmake/Modules/CocosBuildHelpers.cmake:277 (find_package)
cocos2d/cmake/Modules/CocosConfigDepend.cmake:16 (cocos_find_package)
cocos2d/cmake/Modules/CocosConfigDepend.cmake:91 (cocos2dx_depend)
cocos2d/cocos/CMakeLists.txt:131 (use_cocos2dx_libs_depend)
This warning is for project developers. Use -Wno-dev to suppress it.

– OpenGL include dirs: /usr/include
– CURL include dirs: /usr/include
– SQLite3 include dirs: /usr/include
– Configuring done
– Generating done
– Build files have been written to: /home/juriel/cocos/Test6
[juriel@localhost Test6]$

I am encountering this same issue with MacOS (10.14.2) + Android Studio (3.3) + Cocos2d-x (3.17.1).

I was able to resolve this problem by downgrading the version of CMake that Android Studio is using.

Android Studio currently installs CMake version 3.10.2.4988404. By downgrading this to version 3.6.4111459 from within the SDK Manager, I was able to compile a fresh project correctly.

Even though downgrading CMake has allowed you to build the project successfully, it hasn’t fixed the underlying problem though. It’s more of a band-aid solution, and it would be great to figure out the reason why the build fails with CMake 3.10.2, so the real issue can be addressed.

Are you getting any PIE compile errors?

Hey, I’m trying to compile the version downloaded from Github on my Ubuntu 18.06 machine and I’m encountiering the PIE errors:

    /usr/bin/ld: ../cocos2d/external/freetype2/prebuilt/linux/64-bit/libfreetype.a(ftbase.linux64.o): relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIC
    /usr/bin/ld: ../cocos2d/external/freetype2/prebuilt/linux/64-bit/libfreetype.a(ftinit.linux64.o): relocation R_X86_64_32 against symbol `tt_driver_class' can not be used when making a PIE object; recompile with -fPIC
    /usr/bin/ld: ../cocos2d/external/freetype2/prebuilt/linux/64-bit/libfreetype.a(ftsystem.linux64.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC

Any tips?

Take a look at this PR I started.

1 Like

Thanks, I added the line to CMakeLists.txt and it seems to have done the trick!