5

How do I correctly link to CUBLAS in CMake 3.11?

In particular, I'm trying to create a CMakeLists file for this code.

CMakeLists file so far:

cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
project(cmake_and_cuda LANGUAGES CXX CUDA)
add_executable(mmul_2 mmul_2.cu)

This gives multiple "undefined reference errors" to cublas and curand.

Armin Meisterhirn
  • 801
  • 1
  • 13
  • 26
  • Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Tsyvarev Jul 09 '18 at 05:29

1 Answers1

6

Found the solution which is to add this line in the end of the CMakeLists file:

target_link_libraries(mmul_2 -lcublas -lcurand)
Armin Meisterhirn
  • 801
  • 1
  • 13
  • 26