Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
CMake:无法创建目标,因为已存在另一个同名的目标_Cmake_Pthreads - Fatal编程技术网

CMake:无法创建目标,因为已存在另一个同名的目标

CMake:无法创建目标,因为已存在另一个同名的目标,cmake,pthreads,Cmake,Pthreads,我想用cmake安装plexe相扑。我在plexe.car2x.org上学习了教程,结果如下: -- CMAKE_BUILD_TYPE: Release -- CMAKE_BINARY_DIR: /home/cc/src/plexe-sumo/build-release -- CMAKE_SOURCE_DIR: /home/cc/src/plexe-sumo -- -- Platform: -- Host: Linux4.15.0-34-genericx86_64 -- CM

我想用cmake安装plexe相扑。我在plexe.car2x.org上学习了教程,结果如下:

-- CMAKE_BUILD_TYPE: Release
-- CMAKE_BINARY_DIR: /home/cc/src/plexe-sumo/build-release
-- CMAKE_SOURCE_DIR: /home/cc/src/plexe-sumo
-- 
-- Platform: 
--     Host: Linux4.15.0-34-genericx86_64
--     CMake: 3.12.2
--     CMake generator: Unix Makefiles
--     CMake build tool: /usr/bin/make
-- 
-- Found Proj: /usr/lib/x86_64-linux-gnu/libproj.so
CMake Error at /usr/local/share/cmake-3.12/Modules/UseSWIG.cmake:627 (add_custom_target):
  add_custom_target cannot create target "libsumo_swig_compilation" because
  another target with the same name already exists.  The existing target is a
  custom target created in source directory
  "/home/cc/src/plexe-sumo/src/libsumo".  See documentation for policy
  CMP0002 for more details.
Call Stack (most recent call first):
  src/libsumo/CMakeLists.txt:39 (SWIG_ADD_LIBRARY)


-- Enabled features: Linux-4.15.0-34-generic Proj GUI GDAL OSG GL2PS SWIG
-- Configuring incomplete, errors occurred!
“/home/cc/src/plexe-sumo/src/libsumo”下没有名为“libsumo\u swig\u compilation”的文件

然后,我检查了错误日志文件,但显示的错误是关于pthread的“未定义对pthread_create的引用”和“找不到-lpthreads”。实际上,我的pthread库安装在'libc6:/lib/x86_64-linux-gnu/libpthread.so.0'上

所以我想知道这里的确切问题是什么,以及如何解决它。我使用的是一个带有ubuntu 16的虚拟机。我感谢你的帮助

以下是错误日志文件:

Determining if the pthread_create exist failed with the following output:
Change Dir: /home/cc/src/plexe-sumo/build-release/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_050d5/fast"
/usr/bin/make -f CMakeFiles/cmTC_050d5.dir/build.make CMakeFiles/cmTC_050d5.dir/build
make[1]: Entering directory '/home/cc/src/plexe-sumo/build-release/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_050d5.dir/CheckSymbolExists.c.o
/usr/bin/cc   -Wall -pedantic -Wextra    -o CMakeFiles/cmTC_050d5.dir/CheckSymbolExists.c.o   -c /home/cc/src/plexe-sumo/build-release/CMakeFiles/CMakeTmp/CheckSymbolExists.c
/home/cc/src/plexe-sumo/build-release/CMakeFiles/CMakeTmp/CheckSymbolExists.c: In function ‘main’:
/home/cc/src/plexe-sumo/build-release/CMakeFiles/CMakeTmp/CheckSymbolExists.c:8:11: warning: ISO C forbids conversion of function pointer to object pointer type [-Wpedantic]
   return ((int*)(&pthread_create))[argc];
           ^
Linking C executable cmTC_050d5
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_050d5.dir/link.txt --verbose=1
/usr/bin/cc  -Wall -pedantic -Wextra     -rdynamic CMakeFiles/cmTC_050d5.dir/CheckSymbolExists.c.o  -o cmTC_050d5 
CMakeFiles/cmTC_050d5.dir/CheckSymbolExists.c.o: In function `main':
CheckSymbolExists.c:(.text+0x16): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_050d5.dir/build.make:86: recipe for target 'cmTC_050d5' failed
make[1]: *** [cmTC_050d5] Error 1
make[1]: Leaving directory '/home/cc/src/plexe-sumo/build-release/CMakeFiles/CMakeTmp'
Makefile:121: recipe for target 'cmTC_050d5/fast' failed
make: *** [cmTC_050d5/fast] Error 2

File /home/cc/src/plexe-sumo/build-release/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/cc/src/plexe-sumo/build-release/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_9f654/fast"
/usr/bin/make -f CMakeFiles/cmTC_9f654.dir/build.make CMakeFiles/cmTC_9f654.dir/build
make[1]: Entering directory '/home/cc/src/plexe-sumo/build-release/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_9f654.dir/CheckFunctionExists.c.o
/usr/bin/cc   -Wall -pedantic -Wextra -DCHECK_FUNCTION_EXISTS=pthread_create   -o CMakeFiles/cmTC_9f654.dir/CheckFunctionExists.c.o   -c /usr/local/share/cmake-3.12/Modules/CheckFunctionExists.c
Linking C executable cmTC_9f654
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_9f654.dir/link.txt --verbose=1
/usr/bin/cc  -Wall -pedantic -Wextra -DCHECK_FUNCTION_EXISTS=pthread_create    -rdynamic CMakeFiles/cmTC_9f654.dir/CheckFunctionExists.c.o  -o cmTC_9f654 -lpthreads 
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_9f654.dir/build.make:86: recipe for target 'cmTC_9f654' failed
make[1]: *** [cmTC_9f654] Error 1
make[1]: Leaving directory '/home/cc/src/plexe-sumo/build-release/CMakeFiles/CMakeTmp'
Makefile:121: recipe for target 'cmTC_9f654/fast' failed
make: *** [cmTC_9f654/fast] Error 2
确定pthread_create exist是否失败,输出如下:
变更目录:/home/cc/src/plexe sumo/build release/CMakeFiles/CMakeTmp
运行构建命令:“/usr/bin/make”“cmTC_050d5/fast”
/usr/bin/make-f CMakeFiles/cmTC_050d5.dir/build.make CMakeFiles/cmTC_050d5.dir/build
make[1]:输入目录“/home/cc/src/plexe sumo/build release/CMakeFiles/CMakeTmp”
构建C对象cmakfiles/cmTC_050d5.dir/CheckSymbolExists.C.o
/usr/bin/cc-Wall-pedantic-Wextra-o CMakeFiles/cmTC_050d5.dir/CheckSymbolExists.c.o-c/home/cc/src/plexe sumo/build release/CMakeFiles/CMakeTmp/CheckSymbolExists.c
/home/cc/src/plexe sumo/build release/CMakeFiles/CMakeTmp/CheckSymbolExists.c:在函数“main”中:
/home/cc/src/plexe sumo/build release/CMakeFiles/CMakeTmp/CheckSymbolExists.c:8:11:警告:ISO c禁止将函数指针转换为对象指针类型[-Wpedantic]
返回((int*)(&pthread_create))[argc];
^
链接C可执行文件cmTC_050d5
/usr/local/bin/cmake-E cmake_link_脚本CMakeFiles/cmTC_050d5.dir/link.txt--verbose=1
/usr/bin/cc-Wall-pedantic-Wextra-rdynamic CMakeFiles/cmTC_050d5.dir/CheckSymbolExists.c.o-o cmTC_050d5
CMakeFiles/cmTC_050d5.dir/CheckSymbolExists.c.o:在函数“main”中:
CheckSymbolExists.c:(.text+0x16):未定义对“pthread_create”的引用
collect2:错误:ld返回了1个退出状态
CMakeFiles/cmTC_050d5.dir/build.make:86:目标“cmTC_050d5”的配方失败
生成[1]:***[cmTC_050d5]错误1
make[1]:离开目录“/home/cc/src/plexe sumo/build release/CMakeFiles/CMakeTmp”
Makefile:121:目标“cmTC_050d5/fast”的配方失败
制造:**[cmTC_050d5/fast]错误2
文件/home/cc/src/plexe sumo/build-release/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#包括
int main(int argc,字符**argv)
{
(无效)argv;
#ifndef pthread_创建
返回((int*)(&pthread_create))[argc];
#否则
(无效)argc;
返回0;
#恩迪夫
}
确定pthread_create函数是否存在于pthread中失败,输出如下:
变更目录:/home/cc/src/plexe sumo/build release/CMakeFiles/CMakeTmp
运行构建命令:“/usr/bin/make”“cmTC_9f654/fast”
/usr/bin/make-f CMakeFiles/cmTC_9f654.dir/build.make CMakeFiles/cmTC_9f654.dir/build
make[1]:输入目录“/home/cc/src/plexe sumo/build release/CMakeFiles/CMakeTmp”
构建C对象cmakfiles/cmTC_9f654.dir/CheckFunctionExists.C.o
/usr/bin/cc-Wall-pedantic-Wextra-DCHECK_FUNCTION_EXISTS=pthread_create-o CMakeFiles/cmTC_9f654.dir/CheckFunctionExists.c.o-c/usr/local/share/cmake-3.12/Modules/CheckFunctionExists.c
链接C可执行文件cmTC_9f654
/usr/local/bin/cmake-E cmake_link_脚本CMakeFiles/cmTC_9f654.dir/link.txt--verbose=1
/usr/bin/cc-Wall-pedantic-Wextra-DCHECK_FUNCTION_EXISTS=pthread_create-rdynamic CMakeFiles/cmTC_9f654.dir/CheckFunctionExists.c.o-o cmTC_9f654-lpthreads
/usr/bin/ld:找不到-lpthreads
collect2:错误:ld返回了1个退出状态
CMakeFiles/cmTC_9f654.dir/build.make:86:目标“cmTC_9f654”的配方失败
生成[1]:***[cmTC_9f654]错误1
make[1]:离开目录“/home/cc/src/plexe sumo/build release/CMakeFiles/CMakeTmp”
Makefile:121:目标“cmTC_9f654/fast”的配方失败
make:**[cmTC_9f654/fast]错误2

我的假设是,这确实是一种只有新的cmake才能显示的行为。您可以尝试在CMakeLists.txt的java部分中重命名对libsumo的所有引用,或者在这里简单地使用主线sumo的CMakeLists:

根据脚本,如果找到Python库,它将为Python创建SWIG library
libsumo
,如果找到java库,则为java创建SWIG library。也就是说,如果您的计算机上同时安装了Python和Java库,
libsumo
library会创建两次,这是一个真正的问题。向开发者报告。(Log
CMakeOutput.txt
在这里是不相关的。)@Tsyvarev这可能不是原因,因为python库通常被称为带下划线的_libsumo,除非最近发生了变化。@Michael:有趣。函数
SWIG\u ADD\u LIBRARY(…)
实际上创建了一个库目标,Python名为
\u
,其他语言名为
。但是该函数还创建了一个自定义目标,其名称不依赖于特定于Python的:它总是
\u swig\u compilation
。CMake抱怨的正是这个目标。因此,这可能是CMake发行版的一部分,即function
SWIG_ADD_LIBRARY
中的一个bug。是否有理由不使用发行版附带的CMake,而是构建自己的?谢谢大家。Ubuntu16附带的cmake版本太旧了,所以我必须构建自己的版本…谢谢你的回复。我在CMakeLists.txt中没有找到任何与Java相关的内容。我也尝试过使用相扑的CMakeLists,但它不起作用……我应该尝试一个旧版本的CMake吗?在src/libsumo/CMakeLists.txt中以if JAVA_开头的部分中,用libsumojni替换libsumo,