I updated to cuda 5.0 from 4.2 today and get a lot of linking errors like this:
AddLevel.o: In function __sti____cudaRegisterAll_43_tmpxft_000034f6_00000000_6_AddLevel
_cpp1_ii_f49b3b40':/tmp/tmpxft_000034f6_00000000-3_AddLevel.cudafe1.stub.c:8: undefined
reference to `__cudaRegisterLinkedBinary_43_tmpxft_000034f6_00000000_6_AddLevel_cpp1_ii
_f49b3b40.
Every object file is followed by such an error.
As suggested in many posts I've searched for, I added some cuda libraries at the end of linking command but it still doesn't work:
nvcc -O3 -o iTrace*.o -L/usr/local/hdf5/lib -L/usr/local/cuda/lib64
`sdl-config--libs` -lhdf5 -lmfhdf -ldf -ljpeg -lz -lcuda -lcudart -lcublas_device
-lcudadevrt.
Can anyone help me out on this? I put my full Makefile in the end in case you need it. Also I'm using Kubuntu 12.04 64bit version. My gpu is GeForce GTX 550 Ti with compute capability 2.1. Also I changed all suffix name of source file from .C to .cu, although many of them does not contain any device code. Not sure if that's a problem. It works with nvcc 4.2 though.
BTW, how're those weird long file names with underscore and numbers generated? I searched library files in /usr/local/cuda/lib64 and found that all the functions start with __cudaRegisterLinkedBinary_XX(a number here)_
is included in libcublas_device.a
and libcudadevrt.a
. So I think adding those -l options should work
but it doesn't.
Many thanks.
Here is my Makefile.
HDF_DIR = /usr/local/hdf5
HDF_INCLUDE = /usr/local/hdf5/include
X11_DIR = /usr/X11R6
PRECISION = r8
COMPILER="gnu"
DEBUG="no"
OPENMP="no"
ifeq ($(COMPILER), "gnu")
CC = nvcc
CCxx = nvcc
LDR = nvcc
ifeq ($(DEBUG), "yes")
CFLAGS = -O0
LDFLAGS = -O0
else
CFLAGS = -O3
LDFLAGS = -O3
endif
ifeq ($(OPENMP),"yes")
CFLAGS += -fopenmp
LDFLAGS += -fopenmp
endif
endif
ifeq ($(COMPILER), "intel")
CC = icc
CCxx = icpc
LDR = icpc
ifeq ($(DEBUG), "yes")
CFLAGS = -O0
LDFLAGS = -O0
else
CFLAGS = -fast
LDFLAGS = -fast
endif
ifeq ($(OPENMP),"yes")
CFLAGS += -openmp
LDFLAGS += -openmp
endif
endif
DEFINES = INCLUDE = -I. -I$(HDF_INCLUDE) `sdl-config --cflags` -I$(X11_DIR)/include
LIBS = -L$(HDF_DIR)/lib `sdl-config --libs` -L/usr/local/cuda/lib64\
-lhdf5 -lmfhdf -ldf -ljpeg -lz -lcuda -lcudart -lcublas_device -lcudadevrt
OBJS = AddLevel.o \
CreateNewRays.o \
DefineFieldNames.o \
FieldsToLoad.o \
FindField.o \
GetGrid.o \
Grid_ComputeVertexData.o \
Grid_FindNeighbors.o \
Grid_LoadDataHDF4.o \
Grid_LoadDataHDF5.o \
Grid_ReadGridProperties.o \
Grid_SetSubgridMarker.o \
Grid_constructor.o \
Grid_destructor.o \
InterpretKeyPress.o \
LoadCT.o \
Load_RGBA.o \
ListIO.o \
Ray_GridBoundaryCheck.o \
Ray_Initialize.o \
Ray_InterpolateValue.o \
Ray_Trace.o \
Ray_constructor.o \
RayTraceInteractive.o \
LoadAllData.o \
ReadGridInfo.o \
ReadHierarchyEntry.o \
ResetReloadFlag.o \
UnloadAllData.o \
UnloadGrids.o \
UpdateScreen.o \
TraceAllRays.o \
camera.o \
my_vector.o \
print_help.o
%.o:%.cu
$(CCxx) -arch=sm_21 -rdc=true $(DEFINES) $(INCLUDE) -D$(PRECISION) -g -dc
$(CFLAGS) $*.cu
iTrace: $(OBJS)
$(LDR) $(LDFLAGS) -o iTrace $(OBJS) $(LIBS)
clean:
rm -f *~ *.o iTrace
${OBJS}: typedef.h Grid.h my_vector.h Ray.h precision.h colors.h render.h