c++ - 在 Windows 10 上将 Armadillo 用作带有 CLion 和 CMake 的库的问题

标签 c++ cmake clion armadillo

我正在尝试使用 Armadillo Windows 10 上的 CLion 项目中的库,但是当我尝试通过 Reload CMake Project(使用内置的 CMake 编译器)构建时,此错误会在短时间内出现:

CMake Error at C:/Program Files/JetBrains/CLion 2017.2.3/bin/cmake/share/cmake-3.8/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find Armadillo (missing: ARMADILLO_LIBRARY) (found version
  "0.0.0")
Call Stack (most recent call first):
  C:/Program Files/JetBrains/CLion 2017.2.3/bin/cmake/share/cmake-3.8/Modules/FindPackageHandleStandardArgs.cmake:377 (_FPHSA_FAILURE_MESSAGE)
  C:/Program Files/JetBrains/CLion 2017.2.3/bin/cmake/share/cmake-3.8/Modules/FindArmadillo.cmake:77 (find_package_handle_standard_args)
  CMakeLists.txt:4 (find_package)

我已经从 here 下载了库的内容并将其移动到位于 ${PROGRAM FILES}\Armadillo 的文件夹中。为了在我的项目中使用它,我使用了 FindArmadillo module像这样:

find_package(Armadillo REQUIRED)    # this is where the error occurs
include_directories(${ARMADILLO_INCLUDE_DIRS})
...
add_executable(MyProject ${SOURCE_FILES})
target_link_libraries(MABE ${ARMADILLO_LIBRARIES})

有什么我想念的吗?在我可以在我的项目中使用它之前,我是否必须编译库(或类似的东西)?还是我搞砸了下载?

提前致谢!

最佳答案

不确定这是否仍然相关,但对于小型项目,您可以将解压缩的文件保存在项目根目录中,然后将此行添加到您的 CMakeLists.txt:

target_include_directories(YOURPROJECTNAME PUBLIC armadillo/include)

我只是一个初学者,发现这是添加许多库的最简单的解决方案:)

希望这对您有所帮助!

关于c++ - 在 Windows 10 上将 Armadillo 用作带有 CLion 和 CMake 的库的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46631127/

相关文章:

C++20 概念 : multiple return type requirements?

c++ - 链接 Boost 线程库

c++ - CMake - 两个库中的相同文件名发生冲突

memory - 超大型项目的最佳 CLion VM 内存设置

cmake - 如何使用 CMake 在项目中添加预构建的静态库?

c++ - libwayland 的功能已弃用——替代方案?

c++ - 用非常量变量声明数组大小

c++ - 运算符 << 重载 C++

CMake:子目录中的文件 Globbing

CLion 2022.1 : In template: call to '__builtin_operator_delete' selects non-usual deallocation function in