I’m working a file called “smooth.c” and I want to rename it to “smooth.cu” and have my makefile work with it. Unfortunately, gcc tends to ignore the linking stage with -c and nvcc won’t. Therefore, I get a nice huge
/tmp/tmpxft_000014e5_00000000-9.o: In function `main':
tmpxft_000014e5_00000000-8.i:(.text+0x6c8c): undefined reference to `process_arguments(int, char**)'
tmpxft_000014e5_00000000-8.i:(.text+0x6ca1): undefined reference to `mcalloc(unsigned int, unsigned int)'
tmpxft_000014e5_00000000-8.i:(.text+0x6cb9): undefined reference to `mcalloc(unsigned int, unsigned int)'
tmpxft_000014e5_00000000-8.i:(.text+0x6cd1): undefined reference to `mcalloc(unsigned int, unsigned int)'
tmpxft_000014e5_00000000-8.i:(.text+0x6ce9): undefined reference to `mcalloc(unsigned int, unsigned int)'
tmpxft_000014e5_00000000-8.i:(.text+0x6d14): undefined reference to `mcalloc(unsigned int, unsigned int)'
tmpxft_000014e5_00000000-8.i:(.text+0x6ea6): undefined reference to `readNDVIpixel(double*, int, int)'
tmpxft_000014e5_00000000-8.i:(.text+0x6ed0): undefined reference to `windowed_coefs(double*, double*, int, double**, double*)'
tmpxft_000014e5_00000000-8.i:(.text+0x6efb): undefined reference to `writeNDVIpixel(double*, int, int)'
tmpxft_000014e5_00000000-8.i:(.text+0x6f08): undefined reference to `writeASCIIpixel(double*)'
tmpxft_000014e5_00000000-8.i:(.text+0x70bd): undefined reference to `writeNDVIpixelBuffer()'
collect2: ld returned 1 exit status
my makefile with the .c code looks like this
COMMONOBJECTS = memmgr.o 64bitUtility.o
SMOBJECTS = smooth.o lfit.o
NDOBJECTS = n2date.o NDVI2date.o
OBJECTS = $(SMOBJECTS) $(NDOBJECTS) $(COMMONOBJECTS)
EXE = smooth NDVI2date
LDFLAGS = -lm
CFLAGS = -O -D _LARGEFILE_SOURCE -D _FILE_OFFSET_BITS=64
CC = nvcc
default: $(EXE)
smooth: $(SMOBJECTS) $(COMMONOBJECTS)
NDVI2date: $(NDOBJECTS) $(COMMONOBJECTS)
memmgr.o: memmgr.c memmgr.h system.h
smooth.o: smooth.c init.h utility.h system.h memmgr.h lfit.h
64bitUtility.o: 64bitUtility.c system.h utility.h memmgr.h
lfit.o: lfit.c lfit.h utility.h memmgr.h system.h
n2date.o: n2date.c n2date.h memmgr.h
NDVI2date.o: NDVI2date.c init.h utility.h system.h memmgr.h n2date.h
clean:
rm $(OBJECTS) >&/dev/null
rm $(EXE) >&/dev/null
adding
nvcc -c -o smooth.o smooth.cu
and changing the smooth.c to smooth.cu doesn’t work and neither does running a simple nvcc compile command either.
The includes that the smooth.cu file needs are
#include "init.h"
#include "utility.h"
#include "system.h"
#include "memmgr.h"
#include "lfit.h"
#include <stdio.h>
#include <stdlib.h>
Any suggestions?