skrieder
skrieder

Reputation: 399

compiling cuda with gcc results in: error: ‘threadIdx’ undeclared

How can I force GCC to compile with threadIdx lines in my code?

I'm attempting to compile my cuda application with a c wrapper.

To generate the .so file I run: nvcc -arch=sm_11 -o libtest.so --shared -Xcompiler -fPIC main.cu

Then I attempt to compile the c wrapper with: gcc -std=c99 -I/usr/local/cuda/include -o main -L. -ltest main.c

This results in the following error a few layers down in my code(an include to an included file): error: ‘threadIdx’ undeclared

Note: Everything does compile and run just fine as a GPU application without any C wrapping.

Upvotes: 0

Views: 936

Answers (1)

Fr34K
Fr34K

Reputation: 544

Gcc has no capability to compile the cuda part of the code. You need nvcc to compile the code. gcc does not know what to do when it came across threadIdx is.

Upvotes: 1

Related Questions