# Makefile with \*.cu and \*.cpp

**URL:** <https://forums.developer.nvidia.com/t/makefile-with-cu-and-cpp/24975>\
**Category:** CUDA Programming and Performance\
**Created:** [November 21, 2011, 1:42pm UTC](https://forums.developer.nvidia.com/t/makefile-with-cu-and-cpp/24975 "2011-11-21T13:42:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonhydt](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Jonhydt](https://forums.developer.nvidia.com/u/Jonhydt)\
**Post date:** [November 21, 2011, 1:42pm UTC](https://forums.developer.nvidia.com/t/makefile-with-cu-and-cpp/24975/1 "2011-11-21T13:42:48Z")

</div>

Hello,  
I am new in this forum, and i am having problem doing a make file to use \*.cu and \*.cpp files.

CUDA\_INSTALL\_PATH ?=/usr/local/cuda  
CUDA\_SDK\_PATH ?= /home/grasp/NVIDIA\_GPU\_Computing\_SDK

CC=g++  
NVCC := /usr/local/cuda/bin/nvcc  
DEPS= /home/grasp/IVT/src/Image/ByteImage.h  
OBJS = LoadingImage.o LoadingImage\_kernels.o

INCD = -I$(CUDA\_SDK\_PATH)/C/common/inc -I$(CUDA\_INSTALL\_PATH)/include -I./ -I/home/grasp/IVT/src

# Common flags

COMMONFLAGS += $(INCD)  
NVCCFLAGS += $(COMMONFLAGS)  
CXXFLAGS += $(COMMONFLAGS)  
CFLAGS += $(COMMONFLAGS)

LIB\_CUDA := -L$(CUDA\_INSTALL\_PATH)/lib -lcudart

LoadingImage : $(OBJS)  
$(CC) LoadingImage.o -L/home/grasp/IVT/lib/linux -o LoadingImage -livt

LoadingImage\_kernels.o : LoadingImage\_kernels.cu  
$(NVCC) -c $\< -o $@ $(NVCCFLAGS) -I$(DEPS)  
LoadingImage.o : LoadingImage.cpp  
$(CC) -c $\< -o $@ $(CXXFLAGS)

I don’t know why it doesn’t work. I receive an answer like:  
LoadingImage\_kernels.cu:47: error: â€˜blockIdxâ€™ was not declared in this scope  
LoadingImage\_kernels.cu:47: error: â€˜BlockWidthâ€™ was not declared in this scope  
LoadingImage\_kernels.cu:48: error: â€˜blockIxdâ€™ was not declared in this scope  
LoadingImage\_kernels.cu:48: error: â€˜blockDimâ€™ was not declared in this scope  
LoadingImage\_kernels.cu:48: error: â€˜threadIdxâ€™ was not declared in this scope

Someones has any idea? My program is not correct yet, but this kind of errors means that something wrong is happening.

The other way to solve this problem is that i can use Eclipse, but i tried to compile with Eclipse and i coudn’t make it works.  
Do you know any tutorial to run CUDA compiler in Eclipse?

Thank you.
