gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 21:19:19 26 4
gpt4 key购买 nike

我正在尝试使用 cmake 安装 plexe-sumo。我按照 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_swig_compilation”的文件。

然后我检查了错误日志文件,但显示的错误是关于 pthread 说“未定义对 pthread_creat 的引用”和“找不到 -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

最佳答案

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

关于CMake:无法创建目标,因为另一个具有相同名称的目标已存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52573137/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com