CMake的失败编译

问题描述 投票:1回答:2

我试图在openSUSE 13.2编译的cocos2d-X 3.5和我得到.log文件以下错误:

Determining if the pthread_create exist failed with the following output:
Change Dir: /home/humman/android-dev/cocos2d-x-3.5/cocos2d-x-3.5/build/linux-build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/gmake" "cmTryCompileExec846787943/fast"
/usr/bin/gmake -f CMakeFiles/cmTryCompileExec846787943.dir/build.make CMakeFiles/cmTryCompileExec846787943.dir/build
gmake[1]: Entering directory '/home/humman/android-dev/cocos2d-x-3.5/cocos2d-x-3.5/build/linux-build/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /home/humman/android-dev/cocos2d-x-3.5/cocos2d-x-3.5/build/linux-build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec846787943.dir/CheckSymbolExists.c.o
/usr/bin/cc   -fno-exceptions -std=c99    -o CMakeFiles/cmTryCompileExec846787943.dir/CheckSymbolExists.c.o   -c /home/humman/android-dev/cocos2d-x-3.5/cocos2d-x-3.5/build/linux-build/CMakeFiles/CMakeTmp/CheckSymbolExists.c
Linking C executable cmTryCompileExec846787943
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec846787943.dir/link.txt --verbose=1
/usr/bin/cc   -fno-exceptions -std=c99     CMakeFiles/cmTryCompileExec846787943.dir/CheckSymbolExists.c.o  -o cmTryCompileExec846787943 -rdynamic 
CMakeFiles/cmTryCompileExec846787943.dir/CheckSymbolExists.c.o: In function `main':
CheckSymbolExists.c:(.text+0x16): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
CMakeFiles/cmTryCompileExec846787943.dir/build.make:88: recipe for target 'cmTryCompileExec846787943' failed
gmake[1]: *** [cmTryCompileExec846787943] Error 1
gmake[1]: Leaving directory '/home/humman/android-dev/cocos2d-x-3.5/cocos2d-x-3.5/build/linux-build/CMakeFiles/CMakeTmp'
Makefile:118: recipe for target 'cmTryCompileExec846787943/fast' failed
gmake: *** [cmTryCompileExec846787943/fast] Error 2

File /home/humman/android-dev/cocos2d-x-3.5/cocos2d-x-3.5/build/linux-build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <pthread.h>

int main(int argc, char** argv)
{
  (void)argv;
#ifndef pthread_create
  return ((int*)(&pthread_create))[argc];
#else
  (void)argc;
  return 0;
#endif
}

Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /home/humman/android-dev/cocos2d-x-3.5/cocos2d-x-3.5/build/linux-build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/gmake" "cmTryCompileExec3838281423/fast"
/usr/bin/gmake -f CMakeFiles/cmTryCompileExec3838281423.dir/build.make CMakeFiles/cmTryCompileExec3838281423.dir/build
gmake[1]: Entering directory '/home/humman/android-dev/cocos2d-x-3.5/cocos2d-x-3.5/build/linux-build/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /home/humman/android-dev/cocos2d-x-3.5/cocos2d-x-3.5/build/linux-build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec3838281423.dir/CheckFunctionExists.c.o
/usr/bin/cc   -fno-exceptions -std=c99 -DCHECK_FUNCTION_EXISTS=pthread_create   -o CMakeFiles/cmTryCompileExec3838281423.dir/CheckFunctionExists.c.o   -c /usr/share/cmake/Modules/CheckFunctionExists.c
Linking C executable cmTryCompileExec3838281423
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec3838281423.dir/link.txt --verbose=1
/usr/bin/cc   -fno-exceptions -std=c99 -DCHECK_FUNCTION_EXISTS=pthread_create    CMakeFiles/cmTryCompileExec3838281423.dir/CheckFunctionExists.c.o  -o cmTryCompileExec3838281423 -rdynamic -lpthreads 
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
CMakeFiles/cmTryCompileExec3838281423.dir/build.make:88: recipe for target 'cmTryCompileExec3838281423' failed
gmake[1]: *** [cmTryCompileExec3838281423] Error 1
gmake[1]: Leaving directory '/home/humman/android-dev/cocos2d-x-3.5/cocos2d-x-3.5/build/linux-build/CMakeFiles/CMakeTmp'
Makefile:118: recipe for target 'cmTryCompileExec3838281423/fast' failed
gmake: *** [cmTryCompileExec3838281423/fast] Error 2

我手动安装的依赖和库,但我仍然得到这个错误。有谁知道怎么回事?

注:当我尝试编译,第2行是:

~/android-dev/cocos2d-x-3.5/cocos2d-x-3.5/build/linux-build> cmake ../..
CMake Error at CMakeLists.txt:35 (cmake_policy):
  Policy "CMP0054" is not known to this version of CMake.

感谢:D

c++ linux cmake cocos2d-x
2个回答
2
投票

解决了,我只是做在CMakeList.txt文件注释这行了

#if(CMAKE_VERSION VERSION_GREATER 3)
    #cmake_policy(SET CMP0054 NEW)
#endif() 

但现在,当我使用make命令(无论身在何处,使用NetBeans或终端)与它在98%这个错误结束(后约15分钟编译)

[ 98%] Built target cocos2d
[ 98%] Built target MyGame_CORE_PRE_BUILD
MyGame_PRE_BUILD ...
[ 98%] Built target MyGame_PRE_BUILD
Linking CXX executable bin/MyGame
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: lib/libcocos2d.a(CCSpriteFrameCache.cpp.o): undefined reference to symbol '_ZSt28_Rb_tree_rebalance_for_erasePSt18_Rb_tree_node_baseRS_@@GLIBCXX_3.4'
/usr/lib64/libstdc++.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/MyGame.dir/build.make:164: recipe for target 'bin/MyGame' failed
make[2]: *** [bin/MyGame] Error 1
CMakeFiles/Makefile2:64: recipe for target 'CMakeFiles/MyGame.dir/all' failed
make[1]: *** [CMakeFiles/MyGame.dir/all] Error 2
Makefile:76: recipe for target 'all' failed
make: *** [all] Error 2

任何想法??


解决了,如果任何人有同样的问题,只是使用cmake的使用参数-pthread,然后你就可以使用make来构建。如果你想建立使用NetBeans,我只好只留下-G“Unix的......”的说法,并在CMakefile.txt添加一行:设置(-pthread) - 我没有在top--和多数民众赞成它添加首先,它应该是一切就OK了:d喝彩!


0
投票

这似乎是一个长期存在的CMake的错误。有些东西是哪里错了,CMake的迷糊,并报告这一假问题,而不是真正的错误。

在你的CMakeLists.txt文件中寻找“线索”,并暂时移除。

© www.soinside.com 2019 - 2024. All rights reserved.