Luis G
Luis G

Reputation: 41

Trouble working with CUSPARSE

As I wanted to compile my program (using Cusparse) the following lines appeared:

tmp/tmpxft_00001048_00000000-13_matvec.o: In function main': tmpxft_00001048_00000000-1_matvec.cudafe1.cpp:(.text+0x6d5): undefined reference tocusparseCreate'

The same came out not only for cusparseCreate, but also for cusparseCreateMatDescr, cusparseSetMatType, cusparseSetMatIndexBase, cusparseXcoo2csr, cusparseDsctr, cusparseDcsrmv_v2, cusparseDestroyMatDescr and cusparseDestroy. What does it mean?

Upvotes: 2

Views: 3527

Answers (1)

Tom
Tom

Reputation: 21138

You need to link with the cuSPARSE library. Since you're using Linux, adding -lcusparse to your nvcc command line should be sufficient.

Note that you may also need to add the CUDA libraries path to your LD_LIBRARY_PATH environment variable if the system fails to find the linked libraries when executing.

Upvotes: 5

Related Questions