Ask Your Question

Arch Linux: problems building opencv with cuda; undefined reference to `cblas_dgemm'

asked 2018-01-14 17:23:51 -0500

t03i gravatar image

I am currently trying to build a version of opencv, featuring cuda, on my arch linux computer. For that, I use opencv-cuda-git as base version. Additionally, I modified the PKGBUILD and added additional flags to further adapt opencv to my system.

However, everytime I run the buildprocess (makepkg csri), it fails with following error message:

[ 16%] Building CXX object modules/hdf/CMakeFiles/example_hdf_create_groups.dir/samples/create_groups.cpp.o
cd /home/tobias/builds/opencv-cuda-git/src/opencv/build/modules/hdf && /usr/bin/cmake -E cmake_link_script CMakeFiles/example_hdf_create_groups.dir/link.txt --verbose=1
/bin/g++-6  -std=c++11   -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffast-math -ffunction-sections -fdata-sections  -msse -msse2 -fvisibility=hidden -fvisibility-inlines-hidden -Wno-invalid-offsetof -O3 -DNDEBUG  -DNDEBUG  -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now  -Wl,--gc-sections   -rdynamic CMakeFiles/example_hdf_create_groups.dir/samples/create_groups.cpp.o  -o ../../bin/example_hdf_create_groups  -L/opt/cuda/lib64 ../../lib/ ../../lib/ ../../lib/ ../../lib/ ../../lib/ ../../lib/ ../../lib/ 
../../lib/ undefined reference to `cblas_zgemm'
../../lib/ undefined reference to `cblas_sgemm'
../../lib/ undefined reference to `cblas_dgemm'
../../lib/ undefined reference to `cblas_cgemm'
make[2]: *** [modules/hdf/CMakeFiles/example_hdf_create_groups.dir/build.make:102: bin/example_hdf_create_groups] Error 1
make[2]: Leaving directory '/home/tobias/builds/opencv-cuda-git/src/opencv/build'
make[1]: *** [CMakeFiles/Makefile2:2523: modules/hdf/CMakeFiles/example_hdf_create_groups.dir/all] Error 2
make[1]: Leaving directory '/home/tobias/builds/opencv-cuda-git/src/opencv/build'
make: *** [Makefile:163: all] Error 2

My previous search suggested that this error might occur due to a linking error with cublas. Therefore I tried to add -L/opt/cuda/lib64 and -lcublas to CMAKE_CXX_FLAGS. That made no difference at all.

Suggestions by another blog contained using gcc-6 instead of g++-6. That however yields another error:

[ 16%] Linking CXX executable ../../bin/example_hdf_create_groups
cd /home/tobias/builds/opencv-cuda-git/src/opencv/build/modules/hdf && /usr/bin/cmake -E cmake_link_script CMakeFiles/example_hdf_create_groups.dir/link.txt --verbose=1
/bin/gcc-6  -std=c++11   -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffast-math -ffunction-sections -fdata-sections  -msse -msse2 -fvisibility=hidden -fvisibility-inlines-hidden -Wno-invalid-offsetof -O3 -DNDEBUG  -DNDEBUG  -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now  -Wl,--gc-sections   -rdynamic CMakeFiles/example_hdf_create_groups.dir/samples/create_groups.cpp.o  -o ../../bin/example_hdf_create_groups  -L/opt/cuda/lib64 ../../lib/ ../../lib/ ../../lib/ ../../lib/ ../../lib/ ../../lib/ ../../lib/     
ld: CMakeFiles/example_hdf_create_groups.dir/samples/create_groups.cpp ...
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2018-01-17 06:44:05 -0500

t03i gravatar image

Ok I finally managed to solve it.

I had to additionally link cblas, via CMAKE flag. For a more in-depth answer see here

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-01-14 17:23:51 -0500

Seen: 1,271 times

Last updated: Jan 17 '18