Problem of compile with cuda 5.0 sdk

Hello all,

I have a compilation problem with cuda 5 sdk. Hopefully someone of you can help me.

I have two makefiles:

First

all: build/libaco.a

build/libaco.a: build/ants.o build/graph.o build/util.o build/simpleAntColonyGPU_launcher.cu.o
ar rcuvs build/libaco.a build/*.o

build/simpleAntColonyGPU_launcher.cu.o: src/simpleAntColonyGPU_launcher.cu
/usr/local/cuda-5.0/bin/nvcc --compiler-options -fno-strict-aliasing -arch=sm_35
-I. -I/usr/local/cuda-5.0/include -I/usr/local/cuda-5.0/samples/common/inc -I/usr/lib/openmpi/include -L/usr/lib/openmpi/lib -lmpi -Xcompiler -fopenmp
-DUNIX -O3 $(FLAGS) --ptxas-options=-v -Xptxas -dlcm=cs -o build/simpleAntColonyGPU_launcher.cu.o -c src/simpleAntColonyGPU_launcher.cu

and second makefile

bin/acotsp: libaco liblocalsearch build/acotsp.o build/tsp.o

cp libaco/trunk/build/libaco.a lib/
cp liblocalsearch/trunk/build/liblocalsearch.a lib/

g++ -fPIC -g build/acotsp.o build/tsp.o -L/usr/local/cuda-5.0/lib64 -L/usr/local/cuda-5.0/samples/common/inc -L/usr/local/cuda-5.0/samples/common/lib/linux/x86_64 -lcudart -L./lib/
-laco -I/usr/lib/openmpi/include -L/usr/lib/openmpi/lib -lmpi -lgomp -o bin/acotsp

the first makefile compiles fine, but the second you see the following errors:

tmpxft_00000674_00000000-3_simpleAntColonyGPU_launcher.cudafe1.cpp:(.text+0x954) : undefined reference to cudaSetDevice' tmpxft_00000674_00000000-3_simpleAntColonyGPU_launcher.cudafe1.cpp:(.text+0x961) : undefined reference to cudaGetDevice’
tmpxft_00000674_00000000-3_simpleAntColonyGPU_launcher.cudafe1.cpp:(.text+0x9eb) : undefined reference to cudaMalloc' tmpxft_00000674_00000000-3_simpleAntColonyGPU_launcher.cudafe1.cpp:(.text+0xa45) : undefined reference to cudaMemcpy’

No links with cuda libraries, but apparently everything is properly configured

Any idea?

Many thanks

Solved, the second makefile had dependency conflicts, i have put -lcudart at the end of the line.

g++ -fPIC -g build/acotsp.o build/tsp.o -L/usr/local/cuda-5.0/lib64 -L/usr/local/cuda-5.0/samples/common/inc -L/usr/local/cuda-5.0/samples/common/lib/linux/x86_64 -L./lib/
-laco -I/usr/lib/openmpi/include -L/usr/lib/openmpi/lib -lmpi -lgomp -lcudart -o bin/acotsp