9113303
9113303

Reputation: 872

fatal error: cuda.h: No such file or directory for c++

I am trying some c++ code on CUDA. So first i have to include the header files.But i got error fatal error: cuda.h: No such file or directory. I have tried with g++ compilation on my terminal. g++ c4.cpp -o c3 -lcuda and also tried gcc -I/usr/local/cuda/include -L/usr/local/cuda/lib64 c4.cpp -lcudart -o has_cuda. But both gives result. The header file is not in the location. Anybody knows how to get this file or resolve this issue. (I faced the same import problem for iostream header. But that was due to .h file extension. But for this cuda header file, this logic is not working. For importing #include i have tried like this: g++ c3.cpp -o c3 -lpthread . THis one worked for me.) My code:

#include <iostream>

#include <cuda>
//#include <cuda_runtime.h>
//#include <stdlib>
#include <ctime>


int main()
{
    printf("Hello World");

    return 0;
}

But how to get out of the cuda header problem. I got the same error for . Any help is appreciated.

Upvotes: 1

Views: 5656

Answers (2)

9113303
9113303

Reputation: 872

g++ -I/usr/local/cuda/include c4.cpp -o c3 -L/usr/local/cuda/lib64 -lcudart

This works for me.

Upvotes: 0

Naomi
Naomi

Reputation: 5486

the cuda header file is cuda.h. try

#include <cuda.h>

Your gcc command line should be

g++ -I/usr/local/cuda/include c4.cpp -o c3 -L/usr/local/cuda/lib64 -lcuda

The -I comes before your cpp files. The -L comes before the -l

Upvotes: 3

Related Questions