Error compiling files simple,but not understandable

I’m using CMake + Eclipse in my project (CMake as new build configuration in Eclipse, Eclipse is only as Editor). At firsh time I used GPU VSIPL and everything was fine ,but it was too slow, and I wanted to write in pure CUDA. Found some example, but code do not see basic vars of CUDA headers. The errors are

/home/blackswan/workspace/project/ error: no declaration ‘blockIdx’ in this area of visibility

/home/blackswan/workspace/project/ error: no declaration ‘gridDim’ in this area of visibility

/home/blackswan/workspace/project/ error: no declaration ‘threadIdx’ in this area of visibility

/home/blackswan/workspace/project/ error: no declaration ‘blockDim’ in this area of visibility

/home/blackswan/workspace/project/ error: no declaration ‘__syncthreads’ in this area of visibility

I have included main headers in Eclipse

#include </usr/local/cuda/include/cuda.h>

#include </usr/local/cuda/include/cuda_runtime.h>

and managed include_path in CMakeList file

include_directories ( /usr/include/ usr/local/include/ /usr/local/cuda/include )

link_directories ( /usr/lib/ usr/local/lib/ )

I found declarations in other files (not cuda.h and cuda_runtime.h) but Cmake doesn’t see them and Eclipse too. Where should I set the correct path?

could anybody help?

The first errors suggest that your build process isn’t using nvcc to compile device code.

I configured CMake using FindCUDA and Eclipse tuning instruction for CMake. In Eclipse Cmake is using as external tool for making Makefile for building project. I can’t find in Eclipse or CmakeList.txt where should I set nvcc to compile code? Also Eclipse doesn’t “see” CUDA variables, because it doesn’t “see” many headers of CUDA, which are not included directly, but I don’t know where to set it.

Sorry, I can’t help you with anything to do with Eclipse. There are an awful lot of things which potentially be going wrong in that build chain. All I can suggest is starting at the commands which are actually hitting the compilers and tracing them backwards.

The Cmake tool makes Makefile and I don’t see any reference to nvcc in this file, in Eclipse my project has no support of setting compiler in properties, because it uses this external Makefile. I don’t know where to “dig”. The solution is to to make new project, but I haven’t found good instructions for config.
What method of building do you use? Cmake only? How to edit,debug and code-assisting ?

I restrict myself to working with Linux and OS X. and just use a “plain” toolchain with GNU make. I edit everything with vim and use ipython as my development shell. Pretty old skool. Despite tinkering with various IDEs over a period of time longer that I care to admit (from Lucent Energize and Sun Workshop onwards), I just never found one I thought was a better way to work than the original “New Jersey” style UNIX toolchain I first came in contact with as an university student.

ok, but this way is not for me. I don’t have an expirience with such working and used to deal with visual helpfull IDE’s. Maybe someone else have advice or HOWTO?

I’m the author of FindCUDA, and I just noticed your post.

Could you explain how you are trying to build your CUDA code?

For example, this should be the minimum you need to do (outside of the regular CMake setup code):

find_package(CUDA REQUIRED)



nvcc is invoked by a custom cmake script during compilation. The script should be in the current build directory under CMakeFiles. You can also see the commands that are being run by the script by setting CUDA_VERBOSE_BUILD to ON or TRUE via ccmake or the gui.

I would also suggest using the current CMake 2.8 release candidate (as of yesterday it was RC5) which can be found here: .

I must admit, that I haven’t tested the build in Eclipse, so there may be some bugs.

I created folder, where I copied FindCUDA.cmake. Also I use such CMakeList.txt with my project

cmake_minimum_required(VERSION 2.6.2)





message("CUDA found") 


message("CUDA not found") 



include_directories ( /usr/include/ usr/local/include/ /home/blackswan/workspace/gpuvsipl/include 

/home/blackswan/NVIDIA_GPU_Computing_SDK/C/common/inc /usr/local/cuda/include )

link_directories ( /usr/lib/ usr/local/lib/ )

cuda_add_executable(ptest main.cpp defines.h matutils.h

target_link_libraries(ptest /usr/local/cuda/lib/ 

	/usr/local/cuda/lib/ /home/blackswan/workspace/gpuvsipl/linux32/libgpu_vsip.a


and run CMake as External Tool (Run-> External Tools - >External Tools Configuration) from Eclipse, which I created with some instruction (link onto I lost), to update Makefile. The Build function in Eclipse was also working and making executable.

So your project is compiling now?

Some hints:

If you specified REQUIRED to FindCUDA, then you would never get to the if(CUDA_FOUND) statement. The script should terminate before you get there.

The link_directories ‘usr/local/lib’ seems to be missing a ‘/’ at the beginning. Also look for the missing ‘/’ in include_directories’s usr/local/include.

You shouldn’t shouldn’t need to link against cudart as the cuda_add_executable should do that for you. Also you should use ${CUDA_CUFFT_LIBRARIES} instead of directly referencing the library.

Glad you got something compiled.

The 2.8 release of CMake should include a copy of FindCUDA, so you won’t have to maintain a local copy in the future.

Good Luck!