Compling CUSPARSE code

Dear all,

I’m trying to compile the CUSPARSE example in the NVIDIA CUSPARSE library documentation and am running into a problem: none of the cusparse calls work. I then tried writing the most basic CUSPARSE I think of (called test_CUSPARSE_context.cu):

#include <stdio.h>
#include <cuda_runtime.h>
#include “cusparse.h”

int main() {

// Initializing the cusparse library
cusparseHandle_t handle = 0;
cusparseCreate( &handle );

}

I then compiled it using:
nvcc ./test_CUSPARSE_context.cu -o ./bin/test_CUSPARSE_context

And then I receive the following error:
/tmp/tmpxft_00000dee_00000000-13_test_CUSPARSE_context.o: In function main': tmpxft_00000dee_00000000-1_test_CUSPARSE_context.cudafe1.cpp:(.text+0x18): undefined reference to cusparseCreate’
collect2: ld returned 1 exit status

I receive similar errors if I call other cusparse functions.

I have CUDA 3.2 RC installed. The compiler is able to interpret the cusparse data types (I don’t receive any errors associated with them). Does anyone have any advice on how to proceed?

Sincerely,
Fares

Looks like you are not linking against the cusparse library.

Looks like you are not linking against the cusparse library.

Thanks for the tip. That’s just what it was. I compiled the code using the following command:

nvcc test_CUSPARSE.cu -lcusparse -o ./bin/test_CUSPARSE

with “-lcusparse” added to link to CUSPARSE.

Fares

Thanks for the tip. That’s just what it was. I compiled the code using the following command:

nvcc test_CUSPARSE.cu -lcusparse -o ./bin/test_CUSPARSE

with “-lcusparse” added to link to CUSPARSE.

Fares