Search code examples
c++linker-errorsarmadillolapack

how to link armadillo under linux ubuntu giving linking error


I have compiled the library armadillo installed it with sudo make install. Then I linked it with the following options

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wextra -Wno-long-long -std=c++14 -fext-numeric-literals -Wno-cast-function-type -ffast-math -larmadillo -lblas -lm -llapack")

I get the following linking error bayesian_estimation.cpp:(.text+0x4ad5): undefined reference to `dgemm_'

I also installed lapack and blas with sudo apt-get install


Solution

  • CMAKE_CXX_FLAGS is for compile options (and even then...) You should put these linker flags in differently:

    target_link_libraries(my-target armadillo blas m lapack)