threadIdx undeclared identifier

Hi everybody!
I’m a newbie to CUDA and I have a big problem. I copy the cppIntegration project and I modify the .cu file (without modify the include headers).
The information compiler gives :

error C2065: ‘threadIdx’ undeclared identifier
error C2228: left of ‘.x’ must have class/struct/union
error C2065: ‘threadIdx’ undeclared identifier
error C2228: left of ‘.y’ must have class/struct/union
error C3861: ‘__syncthreads’: identifier not found
error C2065: ‘threadIdx’ undeclared identifier
error C2228: left of ‘.x’ must have class/struct/union
error C3861: ‘__syncthreads’: identifier not found
error C2059: sintax error: ‘<’
error C2059: sintax error: ‘<’

I don’t modify “Custom Build Rule” and “Project properties” (it sets to CUDA Build Rule v.2.3.0).
I also install CUDA vs Wizard but the result is the same.
I compile with nvcc.
Can somebody help me??
Thanks

if you use Visual studio, can you post compilation process information in “output” window?

If you use nvcc, then it should recognize threadIdx without including any header.

You may have forgotten global before the declaration

Yves

Hi there!
Thanks for ur attention and answers.
I fixed the problem (I don’t know how) including the follow lines in my kernel files:

#include <device_launch_parameters.h>
#include <device_functions.h>

Now I have a new problem:
When I try to compile my project on MVS 2008 I have this result:

1>------ Build started: Project: CUDAWinApp1, Configuration: Debug Win32 ------
1>Compiling…
1>nvcc fatal : Don’t know what to do with ‘SDK/C/common/lib"’
1>Compiling…
1>nvcc fatal : Don’t know what to do with ‘SDK/C/common/lib"’
1>Compiling…
1>incrocio.cpp
1>c:\cuda\include\crt/func_macro.h(50) : fatal error C1189: #error : – incorrect inclusion of a cudart header file
1>Build log was saved at “file://c:\Documents and Settings\Lapoleone\Documenti\Visual Studio 2008\Projects\CUDAWinApp1\CUDAWinApp1\Debug\BuildLog.htm”
1>CUDAWinApp1 - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

with this command line:

“C:\CUDA\bin\nvcc.exe” -ccbin “C:\Programmi\Microsoft Visual Studio 9.0\VC\bin” -I"C:\CUDA\include" -I"C:\Documents and Settings\Lapoleone\Impostazioni locali\Dati applicazioni\NVIDIA Corporation\NVIDIA GPU Computing SDK\C\common\inc" -O0 -arch compute_10 -code sm_10 --host-compilation C++ -c -m 32 --library “C:\CUDA\lib” --library “C:\Documents and Settings\Lapoleone\Impostazioni locali\Dati applicazioni\NVIDIA Corporation\NVIDIA GPU Computing SDK\C\common\lib” -o “Debug\CUDAWinApp1.obj” -odir “Debug” -ext none -int real “c:\Documents and Settings\Lapoleone\Documenti\Visual Studio 2008\Projects\CUDAWinApp1\CUDAWinApp1\CUDAWinApp1.vcproj”

if i try to compile my two cuda files separately on windows prompt i get this other result:

C:\CUDA\bin>nvcc -ccbin “C:\Programmi\Microsoft Visual Studio 9.0\VC\bin” -I “C:\CUDA\include” -I “C:\Documents and
Settings\Lapoleone\Impostazioni locali\Dati applicazioni\NVIDIA Corporation\NVIDIA GPU Computing SDK\C\common\inc”
–library “C:\CUDA\lib” --library “C:\Documents and Settings\Lapoleone\Impostazioni locali\Dati applicazioni\NVID
IA Corporation\NVIDIA GPU Computing SDK\C\common\lib” -o “C:\Documents and Settings\Lapoleone\Documenti\Visual Stud
io 2008\Projects\CUDAWinApp1\CUDAWinApp1\Debug\cppIntegration.obj” -int real -c “C:\Documents and Settings\Lapoleon
e\Documenti\Visual Studio 2008\Projects\CUDAWinApp1\CUDAWinApp1\cppIntegration.cu”
nvcc fatal : Don’t know what to do with ‘Studio’

I have no idea.
I couldn’t find anything on Google.
Can you help me???

That is not a solution, you are just hiding your error and pusing it to appear later.

It seems for some reason the compiler is dropping quotation marks and has problems with directories containing a space? (Look at the generated errors! - what is SDK/C/common/lib ? And what is “Studio”?)

Also, why do you include func_macro.h in your incrocio.cpp file? Are you sure it shouldn’t be incrocio.cu?

yes i’m sure. incrocio must be .cpp. it includes a lot of useful functions for my cuda file.

That’s the problem!!! I have no idea how to resolve it. I think it’s really strange.

But it does not have anything cuda-specyfic? No kernels, anything?

i have a cuda host file and a cuda kernel file.

they call incrocio.cpp functions.