Getting an eclipse/nSight g++ project to link to a nvcc static library project

I’m working on sprinkling cuda in an open source project (splat hd). I’ve created a static library project in nsight titled “cudapath” with and cudapath.h with as follows:


bool cudaCapable(void){
	int count;

	CUdevice device;
	CUcontext context;
	if(count > 0){
		cuDeviceGet(&device, 0);
		cuCtxCreate(&context, CU_CTX_SCHED_AUTO, device);
		size_t free;
		size_t total;
		cuMemGetInfo(&free, &total);
		if(free / (1024 * 1024) < 468){
			printf("Device %d has %d MB free, %d MB total/  Need 468mb\n", 0, free / (1024*1024), total / (1024*1024));
			return false;
		} else {
			return true;
	} else {
		return false;

This compiles fine and I end up with cudapath/Debug/cudapath.o and cudapath/Debug/libcudapath.a

The other project is a regular C++ project with a G++ toolchain.

I have the project configured as follows:

And the resulting build string & error in the console when building the G++ project:

Invoking: GCC C++ Linker
g++ -L/usr/local/cuda/lib64 -L"/home/sean/cuda-workspace/cudapath/Debug" -march=x86-64 -o "cudasplat"  ./itwom3.0.o ./splat.o   -lm -lcudart -lcuda -lcudapath -lbz2
/home/sean/cuda-workspace/cudapath/Debug/libcudapath.a(cudapath.o): In function `cudaCapable()':
/home/sean/cuda-workspace/cudapath/Debug/../ undefined reference to `cudaGetDeviceCount'
/home/sean/cuda-workspace/cudapath/Debug/../ undefined reference to `cuDeviceGet'
/home/sean/cuda-workspace/cudapath/Debug/../ undefined reference to `cuCtxCreate_v2'
/home/sean/cuda-workspace/cudapath/Debug/../ undefined reference to `cuMemGetInfo_v2'
/home/sean/cuda-workspace/cudapath/Debug/../ undefined reference to `cuCtxDestroy_v2'

Why can’t it find the cuda functions when the library folder is explicitly specified in the build string? What am I doing wrong?

I solved my own problem. For those curious this article gave me a clue:

I had to change the order of my libraries so that the static library project was linked to first:

Thanks. Solved my problem!