'CGAL::Surface_mesh_parameterization::get_error_message(int)' 的多重定义
multiple definition of 'CGAL::Surface_mesh_parameterization::get_error_message(int)'
我可以轻松地使用给定示例的 CGAL 表面网格参数化。这意味着 CGAL 已正确安装并且可以正常工作。
重现错误的方法:
- 创建一个空的主文件
- 创建一个 class 文件并适当修改 CGAL square_border_parametrize.cpp
- 在我执行
cmake .
和 make
之后,这是输出
Scanning dependencies of target Main
[ 33%] Building CXX object CMakeFiles/Main.dir/SBP.cpp.o
:0:15: warning: missing whitespace after the macro name
:0:15: warning: missing whitespace after the macro name
[ 66%] Building CXX object CMakeFiles/Main.dir/main.cpp.o
:0:15: warning: missing whitespace after the macro name
:0:15: warning: missing whitespace after the macro name
[100%] Linking CXX executable Main
CMakeFiles/Main.dir/main.cpp.o: In function <code>_mm_getcsr()':
/usr/local/include/CGAL/Interval_nt.h:202: multiple definition of
CGAL::Surface_mesh_parameterization::get_error_message(int)'
CMakeFiles/Main.dir/SBP.cpp.o:/usr/local/include/CGAL/Surface_mesh_parameterization/Error_code.h:53: first defined here
collect2: error: ld returned 1 exit status
CMakeFiles/Main.dir/build.make:450: recipe for target 'Main' failed
make[2]: * [Main] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/Main.dir/all' failed
make[1]: * [CMakeFiles/Main.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
我找不到 CGAL::Surface_mesh_parameterization::get_error_message(int)
的任何多重定义。我的 CMakeLists.txt 文件如下所示:
cmake_minimum_required (VERSION 2.8 FATAL_ERROR)
PROJECT(LSCM)
FIND_PACKAGE( OpenCV REQUIRED )
find_package( PCL 1.7 REQUIRED COMPONENTS common io visualization filters )
find_package( CGAL QUIET COMPONENTS )
if ( NOT CGAL_FOUND )
message(STATUS "This project requires the CGAL library, and will not be compiled.")
return()
endif()
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
include( CGAL_CreateSingleSourceCGALProgram )
find_package( Boost REQUIRED )
if ( NOT Boost_FOUND )
message(STATUS "This project requires the Boost library, and will not be compiled.")
return()
endif()
SET(CMAKE_BUILD_TYPE "Debug")
SET(LIBRARY_OUTPUT_PATH "./lib")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
file(GLOB SOURCE_FILES ./*.cpp)
ADD_EXECUTABLE(Main ${SOURCE_FILES})
TARGET_LINK_LIBRARIES(Main ${OpenCV_LIBS} ${PCL_LIBRARIES} ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} -lCGAL -lm )
install (TARGETS Main DESTINATION ~/bin)
快速修复:在文件 include/CGAL/Surface_mesh_parameterization/Error_code.h 中,在 const char* get_error_message(int error_code)
前面写上 inline
。
修复在这个 pull request 中,现在已合并到 CGAL-4.12 中。
我可以轻松地使用给定示例的 CGAL 表面网格参数化。这意味着 CGAL 已正确安装并且可以正常工作。 重现错误的方法:
- 创建一个空的主文件
- 创建一个 class 文件并适当修改 CGAL square_border_parametrize.cpp
- 在我执行
cmake .
和make
之后,这是输出Scanning dependencies of target Main [ 33%] Building CXX object CMakeFiles/Main.dir/SBP.cpp.o :0:15: warning: missing whitespace after the macro name :0:15: warning: missing whitespace after the macro name [ 66%] Building CXX object CMakeFiles/Main.dir/main.cpp.o :0:15: warning: missing whitespace after the macro name :0:15: warning: missing whitespace after the macro name [100%] Linking CXX executable Main CMakeFiles/Main.dir/main.cpp.o: In function <code>_mm_getcsr()': /usr/local/include/CGAL/Interval_nt.h:202: multiple definition of
CGAL::Surface_mesh_parameterization::get_error_message(int)' CMakeFiles/Main.dir/SBP.cpp.o:/usr/local/include/CGAL/Surface_mesh_parameterization/Error_code.h:53: first defined here collect2: error: ld returned 1 exit status CMakeFiles/Main.dir/build.make:450: recipe for target 'Main' failed make[2]: * [Main] Error 1 CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/Main.dir/all' failed make[1]: * [CMakeFiles/Main.dir/all] Error 2 Makefile:140: recipe for target 'all' failed make: *** [all] Error 2
我找不到 CGAL::Surface_mesh_parameterization::get_error_message(int)
的任何多重定义。我的 CMakeLists.txt 文件如下所示:
cmake_minimum_required (VERSION 2.8 FATAL_ERROR)
PROJECT(LSCM)
FIND_PACKAGE( OpenCV REQUIRED )
find_package( PCL 1.7 REQUIRED COMPONENTS common io visualization filters )
find_package( CGAL QUIET COMPONENTS )
if ( NOT CGAL_FOUND )
message(STATUS "This project requires the CGAL library, and will not be compiled.")
return()
endif()
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
include( CGAL_CreateSingleSourceCGALProgram )
find_package( Boost REQUIRED )
if ( NOT Boost_FOUND )
message(STATUS "This project requires the Boost library, and will not be compiled.")
return()
endif()
SET(CMAKE_BUILD_TYPE "Debug")
SET(LIBRARY_OUTPUT_PATH "./lib")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
file(GLOB SOURCE_FILES ./*.cpp)
ADD_EXECUTABLE(Main ${SOURCE_FILES})
TARGET_LINK_LIBRARIES(Main ${OpenCV_LIBS} ${PCL_LIBRARIES} ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} -lCGAL -lm )
install (TARGETS Main DESTINATION ~/bin)
快速修复:在文件 include/CGAL/Surface_mesh_parameterization/Error_code.h 中,在 const char* get_error_message(int error_code)
前面写上 inline
。
修复在这个 pull request 中,现在已合并到 CGAL-4.12 中。