CMakeList 中应包含哪些模块.txt以进行近似最近邻搜索?
What modules should be included in CMakeList.txt for Approximate Nearest Neighbor Searching?
我已经编译了ANN库,需要在C++文件中使用它进行分割评估
我已经设置了CMakeList.txt,它使用ITK和ANN库,如下所示:
PROJECT(EvaluateSegmentationResult)
cmake_minimum_required(VERSION 3.14)
set(ANN_LIB /home/user/tools/ann_1.1.2/lib/)
set(ANN_PATH /home/user/tools/ann_1.1.2/include/)
#FIND_PACKAGE(ITK)
find_package(ITK COMPONENTS
ITKBinaryMathematicalMorphology
ITKCommon
ITKIOImageBase
ITKImageFunction
ITKImageGrid
ITKImageIntensity
ITKMathematicalMorphology
ITKThresholding
ITKImageIO
)
IF(ITK_FOUND)
INCLUDE(${ITK_USE_FILE})
ELSE(ITK_FOUND)
MESSAGE(FATAL_ERROR
"ITK not found. Please set ITK_DIR.")
ENDIF(ITK_FOUND)
FIND_PATH(ANN_PATH NAMES ANN)
FIND_LIBRARY(ANN_LIB NAMES ann PATHS ${ANN_PATH})
INCLUDE_DIRECTORIES(${ANN_PATH})
ADD_EXECUTABLE( EvaluateSegmentationResult EvaluateSegmentationResult.cpp)
#TARGET_LINK_LIBRARIES( EvaluateSegmentationResult ITKIO ITKBasicFilters ITKCommon ${ITK_LIBRARIES} ${ANN_LIB})
TARGET_LINK_LIBRARIES( EvaluateSegmentationResult ${ITK_LIBRARIES} ${ANN_LIB})
但是,一旦我编译C++文件,它就会引发错误:
/home/user/tools/EvaluationSourceCode/EvaluateSegmentationResult.cpp:86: undefined reference to `annAllocPts(int, int)'
/home/user/tools/EvaluationSourceCode/EvaluateSegmentationResult.cpp:95: undefined reference to `ANNkd_tree::ANNkd_tree(double**, int, int, int, ANNsplitRule)'
/home/user/tools/EvaluationSourceCode/EvaluateSegmentationResult.cpp:135: undefined reference to `annAllocPts(int, int)'
/home/user/tools/EvaluationSourceCode/EvaluateSegmentationResult.cpp:144: undefined reference to `ANNkd_tree::ANNkd_tree(double**, int, int, int, ANNsplitRule)'
/home/user/tools/EvaluationSourceCode/EvaluateSegmentationResult.cpp:175: undefined reference to `annDeallocPts(double**&)'
/home/user/tools/EvaluationSourceCode/EvaluateSegmentationResult.cpp:176: undefined reference to `annDeallocPts(double**&)'
collect2: error: ld returned 1 exit status
CMakeFiles/EvaluateSegmentationResult.dir/build.make:128: recipe for target 'EvaluateSegmentationResult' failed
make[3]: *** [EvaluateSegmentationResult] Error 1
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/EvaluateSegmentationResult.dir/all' failed
make[2]: *** [CMakeFiles/EvaluateSegmentationResult.dir/all] Error 2
CMakeFiles/Makefile2:84: recipe for target 'CMakeFiles/EvaluateSegmentationResult.dir/rule' failed
make[1]: *** [CMakeFiles/EvaluateSegmentationResult.dir/rule] Error 2
Makefile:118: recipe for target 'EvaluateSegmentationResult' failed
make: *** [EvaluateSegmentationResult] Error 2
似乎问题与链接库有关。 我应该在CMakeList.txt
中添加任何特定的行或模块吗?
这些方法是在 ANN.lib 本身中定义的,因此您不会错过添加任何库。在find_library调用中作为 PATH 参数传递的 ${ANN_PATH} 变量指向标头包含文件夹。您应该让它指向包含库的文件夹,并在继续target_link_libraries调用之前执行 if 检查以查看是否已找到它。
我可以通过在target_link_libraries()
调用中添加-lANN -LlibANN
来解决问题:
TARGET_LINK_LIBRARIES( EvaluateSegmentationResult ${ITK_LIBRARIES} -lANN -LlibANN)
相关文章:
- 查找最近配对时的OpenMP竞赛条件
- 如何获取pcl迭代最近点(ICP)的迭代点数?
- 如何使用 OpenMP 并行化最近邻搜索
- 如何找到给定点的最近平方
- 将前向声明的结构替换为最近定义的结构
- CMakeList 中应包含哪些模块.txt以进行近似最近邻搜索?
- 应该如何编写用于计算最近点距离的C++函数?
- 最近的邻居用nanoflann搜索
- GCC:--静态链接到pthread的整个存档配方在最近的GCC版本中停止工作
- 向下四舍五入到五个c++的最近倍数
- 在 3D 点云、GPU 中查找最近的邻居
- 我最近更改了编译器路径以运行 c++ 代码,但现在我无法运行任何 python 代码。我该如何解决这个问题?
- 在RHEL6上使用最近的gcc进行编译:如何分发软件?
- 最近最少使用的 (LRU) 缓存
- 我最近正在阅读opencv源代码。有没有更好的方法来在opencv库中查找类定义?
- c++ Valgrind:地址0x0不是堆叠的、恶意的或(最近)释放的
- 如何在无限轴上找到 N 个点,以便从 M 点到其最近的 N 的距离总和最小
- 地址0x20ec8348e5894855不是堆叠的、恶意的或(最近)释放的
- 在 OpenCV 和 C++ 中查找距轮廓中心最近的黑色像素
- 'new'关键字如何工作?我最近才知道新关键字