I am using cmake 3.16
, and I know that cmake supports finding OpenBLAS
by using FindBLAS
(here).
I am trying to link OpenBLAS
to my c++ project. Here is my CMakeLists.txt
.
cmake_minimum_required(VERSION 3.15)
project(my_project)
# source file
file(GLOB SOURCES "src/*.cpp")
# executable file
add_executable(main.exe ${SOURCES})
# link openblas
set(BLA_VENDER OpenBLAS)
find_package(BLAS REQUIRED)
if(BLAS_FOUND)
message("OpenBLAS found.")
include_directories(${BLAS_INCLUDE_DIRS})
target_link_libraries(main.exe ${BLAS_LIBRARIES})
endif(BLAS_FOUND)
If I run cmake
, it runs just find, and outputs OpenBLAS found.
. However, if I start to compile the codes (make VERBOSE=1
), the library is not linked, so that the codes fail to compile. Here is the error info:
fatal error: cblas.h: No such file or directory
#include <cblas.h>
^~~~~~~~~
compilation terminated.
I installed OpenBLAS successfully. The header files are in /opt/OpenBLAS/include
, and the shared libraries are in /opt/OpenBLAS/lib
. My OS is ubuntu 18.04.
Any help? Thank you!