在archlinux上编译项目报错

使用 aur 里的源码安装上了 ,fmod 的问题也 因为 安装 fmodex 的包解决了。现在又碰到了这个问题

google 了没找到 解决办法 ,所以我把错误贴出来

┌─(/opt/cocos2d-x/build/linux-build)────────────────────────────────────(blambin@arch-pc:pts/2)─┐
└─(10:19:24)──> sudo make ──(Sat,Mar03)─┘
[sudo] password for blambin:
It appears you are building natively for Linux with GCC
– OpenGL include dirs: /usr/include
– GLEW include dirs: /usr/include
– PkgConfig found
– GLFW3 include dirs: /usr/include/GLFW
– SQLite3 include dirs: /usr/include
– FMOD include dirs: /usr/include
– Fontconfig include dirs: /usr/include/freetype2;/usr/include/libpng16;/usr/include/harfbuzz;/usr/include/glib-2.0;/usr/lib/glib-2.0/include;/usr/include/freetype2;/usr/include/libpng16;/usr/include/harfbuzz;/usr/include/glib-2.0;/usr/lib/glib-2.0/include
– GTK3 include dirs: /usr/include/gtk-3.0;/usr/include/at-spi2-atk/2.0;/usr/include/at-spi-2.0;/usr/include/dbus-1.0;/usr/lib/dbus-1.0/include;/usr/include/gtk-3.0;/usr/include/gio-unix-2.0/;/usr/include/cairo;/usr/include/pango-1.0;/usr/include/atk-1.0;/usr/include/cairo;/usr/include/pixman-1;/usr/include/freetype2;/usr/include/libpng16;/usr/include/harfbuzz;/usr/include/glib-2.0;/usr/lib/glib-2.0/include;/usr/include/freetype2;/usr/include/harfbuzz;/usr/include/libpng16;/usr/include/gdk-pixbuf-2.0;/usr/include/glib-2.0;/usr/lib/glib-2.0/include
– Freetype include dirs: /usr/include/freetype2;/usr/include/libpng16;/usr/include/harfbuzz;/usr/include/glib-2.0;/usr/lib/glib-2.0/include
– WebP include dirs: /usr/include/webp
– Bullet include dirs: /opt/cocos2d-x/external/bullet/include;/opt/cocos2d-x/external/bullet/include/bullet
CMake Error at cmake/Modules/CocosBuildHelpers.cmake:44 (find_package):
By not providing “Findrecast.cmake” in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by “recast”, but
CMake did not find one.

Could not find a package configuration file provided by “recast” with any
of the following names:

recastConfig.cmake
recast-config.cmake

Add the installation prefix of “recast” to CMAKE_PREFIX_PATH or set
“recast_DIR” to a directory containing one of the above files. If “recast”
provides a separate development package or SDK, be sure it has been
installed.
Call Stack (most recent call first):
cmake/Modules/BuildModules.cmake:81 (cocos_find_package)
CMakeLists.txt:98 (BuildModules)

– Configuring incomplete, errors occurred!
See also “/opt/cocos2d-x/build/linux-build/CMakeFiles/CMakeOutput.log”.
See also “/opt/cocos2d-x/build/linux-build/CMakeFiles/CMakeError.log”.
make: *** [Makefile:440: cmake_check_build_system] Error 1

找不到recast这个第三方库,不知道你用的是哪个版本的cocos2d-x,最新版本的recast已经作为源码在第三方库中,引用对应的cmake文件,编译库。recast 源码在这里 https://github.com/cocos2d/cocos2d-x-3rd-party-libs-bin/tree/v3/recast

在引擎的cmake中的使用方式类似:

      set(_recast_prefix RECAST)
      set(RECAST_INCLUDE_DIRS ${COCOS2DX_ROOT_PATH}/external/recast)
      add_subdirectory(${COCOS2DX_ROOT_PATH}/external/recast)
      set(RECAST_LIBRARIES recast)

使用这种方式提供了第三方库,就可以把 cocos_find_package(recast RECAST REQUIRED) 注释掉,提供了这些环境变量之后,使用库的时候会调用,function(cocos_use_pkg target pkg),这个方法会用到上述提供的变量

我检查了一下,可能 是因为上一步没有 编译完…

在 build目录 运行的时候 还是有问题

┌─(/opt/cocos2d-x/build)──────────────────────────────(blambin@arch-pc:pts/0)─┐
└─(14:24:30)──> make ──(Sat,Mar03)─┘
[ 2%] Built target recast
[ 2%] Built target tinyxml2
[ 2%] Built target unzip
[ 3%] Built target flatbuffers
[ 4%] Built target xxhash
[ 68%] Built target cocos2dInternal
[ 68%] Built target cocos2d
[ 68%] Linking CXX executable …/…/bin/cpp-empty-test/cpp-empty-test
/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 /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
/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 /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 shared object; recompile with -fPIC
/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 shared object; recompile with -fPIC /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 shared object; recompile with -fPIC
/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 shared object; recompile with -fPIC /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 shared object; recompile with -fPIC
/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 shared object; recompile with -fPIC /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 shared object; recompile with -fPIC
/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 shared object; recompile with -fPIC /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 shared object; recompile with -fPIC
/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 shared object; recompile with -fPIC /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 shared object; recompile with -fPIC
/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 shared object; recompile with -fPIC /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 shared object; recompile with -fPIC
/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 shared object; recompile with -fPIC /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 shared object; recompile with -fPIC
/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 shared object; recompile with -fPIC /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 shared object; recompile with -fPIC
/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 shared object; recompile with -fPIC /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 shared object; recompile with -fPIC
/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 shared object; recompile with -fPIC /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 shared object; recompile with -fPIC
/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 shared object; recompile with -fPIC /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 shared object; recompile with -fPIC
/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 shared object; recompile with -fPIC /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 shared object; recompile with -fPIC
/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 shared object; recompile with -fPIC /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 shared object; recompile with -fPIC
/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 shared object; recompile with -fPIC /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 shared object; recompile with -fPIC
/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 shared object; recompile with -fPIC /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 shared object; recompile with -fPIC
/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 shared object; recompile with -fPIC /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 shared object; recompile with -fPIC
/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 shared object; recompile with -fPIC /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 shared object; recompile with -fPIC
/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 shared object; recompile with -fPIC /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 shared object; recompile with -fPIC
/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 shared object; recompile with -fPIC /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 shared object; recompile with -fPIC
/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 shared object; recompile with -fPIC /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 shared object; recompile with -fPIC
/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 shared object; recompile with -fPIC /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 shared object; recompile with -fPIC
/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 shared object; recompile with -fPIC /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 shared object; recompile with -fPIC
/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 shared object; recompile with -fPIC /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 shared object; recompile with -fPIC
/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 shared object; recompile with -fPIC /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 shared object; recompile with -fPIC
/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 shared object; recompile with -fPIC /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 shared object; recompile with -fPIC
/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
make[2]: *** [tests/cpp-empty-test/CMakeFiles/cpp-empty-test.dir/build.make:175: bin/cpp-empty-test/cpp-empty-test] Error 1
make[1]: *** [CMakeFiles/Makefile2:467: tests/cpp-empty-test/CMakeFiles/cpp-empty-test.dir/all] Error 2
make: *** [Makefile:84: all] Error 2


网上查到说可能 是gcc 版本的问题,但是arch编译其它版本的gcc并不方便。还有其它的办法 吗

gcc --version
gcc (GCC) 7.3.0
Copyright © 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

cocos2d-x/build/install-deps-linux.sh 提供的信息依赖的gcc版本是

DEPENDS+=' gcc-4.9'
DEPENDS+=' g++-4.9'

你可以按照这个来搞