Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

compiling cuda file in makefile error

I have made a makefile in order to compile my files:

CFLAGS        = -O3 -Wall -I /usr/local/cuda/include/ 
NVCCFLAGS     = -O3 -arch sm_20
LDFLAGS       = -O3 -L/usr/local/cuda/lib64 -lcudart
EXE           =  runAPP

app.o:app.cu
$(NVCC) $(NVCCFLAGS) -c $< -o $(CPPFLAGS) $(LIB_PATH) $(LDFLAGS) $@

$(EXE): app.o 
    $(NVCC) $(NVCCFLAGS) $(CFLAGS) $(LDFLAGS) -o $@  $(CPPFLAGS) $(LIB_PATH) app.o  \
        -lANN_char -lz
    cp $@ ../bin

But I got this problem:

app.cpp:26:26: error: cuda_runtime.h: No such file or directory app.cpp:27:18: error: cuda.h: No such file or directory

This is how I include them in the app.cpp:

#include <cuda.h>
#include <cuda_runtime.h>

Why is this problem?

I search something on google, they said that the app.cpp must be always app.cu, is it true?

Thanks in advance.

like image 589
olidev Avatar asked Apr 27 '26 19:04

olidev


1 Answers

If your makefile, you have:

CFLAGS        = -O3 -Wall -I /usr/local/cuda/include/ 
NVCCFLAGS     = -O3 -arch sm_20
LDFLAGS       = -O3 -L/usr/local/cuda/lib64 -lcudart
EXE           =  runAPP

app.o:app.cu $(NVCC) $(NVCCFLAGS) -c $< -o $(CPPFLAGS) $(LIB_PATH) $(LDFLAGS) $@

CPPFLAGS should be expanding to nothing; try changing it to CFLAGS, or change CFLAGS to CPPFLAGS.

like image 121
trycatch Avatar answered Apr 30 '26 11:04

trycatch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!