Issue with classes in *.cu file when used as a library (solved)

I have been researching how to do this type of makefile for the past few days and have tried several things, but now I am out of ideas. I would greatly appreciate any insight as to where I am going wrong (this code works fine in Visual Studio btw!). I just do not know enough about compiling and linking CUDA in Linux to figure out if I have a typo or a general mis-understanding of how linking a CUDA library works.

I have a *.cu header file with an object that sets up parameters for memory allocation on the GPU. I also have cuda kernels and other things in this file, but I took it all out to debug, and besides, the errors appear to only be in relation to creating and destroying this object (at least that is where the code gets hung up right now). I have another library of c++11 code that I link to the main *.cpp file as well.

The error I get when I try to link is this:

main.o: In function main': main.cpp:(.text.startup+0x1a): undefined reference to param::param(unsigned int, unsigned int, unsigned int)’
main.cpp:(.text.startup+0x22): undefined reference to `param::~param()’

My cuda header file is:


class TPSwarp_cuparam : public TPSwarp_param
	param(uint nm, uint ni, uint nj);
	uint max_L_mem_size;
//and so forth...


#include "param.h"

param::param(uint nm, uint ni, uint nj)
	max_L_mem_size =nm*ni*nj;


#include "param.h"

int main(int argc, char *argv[]) 
	param test(10,5,5);



my makefile contains this:

CUDA_PATH       ?= /usr/local/cuda-6.0
-I$(CUDA_PATH)/include \
CCFLAGS = -Xcompiler #basically some stuff copied from cuda sample makefiles...
GENCODE = -gencode arch=compute_20,code=sm_20
NVCC := $(CUDA_PATH)/bin/nvcc -ccbin g++

mainwcuda: cudalibrary main.o
	g++ -std=c++11 -o./Bin/cudaexe main.o -L./ -lcudalibrary -lcpp11library


cudalibrary: param.o
	ar r libcudalibrary.a param.o
	ranlib libcudalibrary.a

main.o: main.cpp
	g++ -std=c++11 $(CUDAFLAGS) $(CUDAINCLUDES) -o $@ $<

EDIT: I figured out what was wrong with my code. After trimming down all my files to just have the bare-minimum code, I found that I had an #ifdef around my class, for cases when cuda is not available. Once I took that out, my code finally was able to create an executable. I will leave this post up in case someone else needs another example of a makefile for cuda as a library.