我正在尝试构建Armadillo C ++库(版本6.6),并且确实可以正常运行。但是,我的问题是我已经分别下载了OpenBLAS的源代码并进行了构建。我希望Armadillo使用我在本地构建的OpenBLAS,并希望将其静态链接到所生成的Armadillo库。
所以,
我如何告诉Armadillo CMake使用特定的OpenBLAS?
我如何告诉Armadillo CMake静态链接上述OpenBLAS,以便产生一个包含我的OpenBLAS的libarmadillo?
最佳答案
如果您从源代码安装了OpenBLAS,则它位于非标准位置(对我而言,位于/ opt / OpenBLAS),并且具有非标准名称(OpenBLAS)。因此,为了解决问题,cmake很难找到它
请按以下方式在your_sources_dir / cmake_aux / Modules / ARMA_FindOpenBLAS.cmake中编辑文件:
set(OpenBLAS_NAMES)
set(OpenBLAS_NAMES ${OpenBLAS_NAMES} openblaso)
set(OpenBLAS_NAMES ${OpenBLAS_NAMES} openblasp)
set(OpenBLAS_NAMES ${OpenBLAS_NAMES} openblas )
set(OpenBLAS_NAMES ${OpenBLAS_NAMES} OpenBLAS )
set(OpenBLAS_TMP_LIBRARY)
set(OpenBLAS_TMP_LIBRARIES)
foreach (OpenBLAS_NAME ${OpenBLAS_NAMES})
find_library(${OpenBLAS_NAME}_LIBRARY
NAMES ${OpenBLAS_NAME}
PATHS ${CMAKE_SYSTEM_LIBRARY_PATH} /lib64 /lib /usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib /opt/local/lib64 /opt/local/lib /opt/OpenBLAS/lib
)
set(OpenBLAS_TMP_LIBRARY ${${OpenBLAS_NAME}_LIBRARY})
if(OpenBLAS_TMP_LIBRARY)
set(OpenBLAS_TMP_LIBRARIES ${OpenBLAS_TMP_LIBRARIES} ${OpenBLAS_TMP_LIBRARY})
endif()
endforeach()
# use only one library
if(OpenBLAS_TMP_LIBRARIES)
list(GET OpenBLAS_TMP_LIBRARIES 0 OpenBLAS_LIBRARY)
endif()
if(OpenBLAS_LIBRARY)
set(OpenBLAS_LIBRARIES ${OpenBLAS_LIBRARY})
set(OpenBLAS_FOUND "YES")
else()
set(OpenBLAS_FOUND "NO")
endif()
if(OpenBLAS_FOUND)
if (NOT OpenBLAS_FIND_QUIETLY)
message(STATUS "Found OpenBLAS: ${OpenBLAS_LIBRARIES}")
endif()
else()
if(OpenBLAS_FIND_REQUIRED)
message(FATAL_ERROR "Could not find OpenBLAS")
endif()
endif()
# mark_as_advanced(OpenBLAS_LIBRARY)
然后使用
cmake.
继续进行犰狳的常规安装希望这个建议对您有帮助。
关于c++ - 如何构建Armadillo C++库以在非标准位置静态链接到OpenBLAS,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36266242/