undefined reference to `$gpu_registers' Linking with ptxvars necessary?

I do:
nvcc -g -G -o test.cu_o -c regression.cu -I/opt/cuda/sdk/common/inc/ -I/usr/local/cuda/include -I/opt/sun-jdk-1.4.2.19/include -I/opt/sun-jdk-1.4.2.19/include/linux
g++ -o CudaCallC test.cu_o -L/opt/cuda/lib -L. -L/usr/local/cuda/lib -lcuda -lcudart

I get:
test.cu_o: In function $$SymbolTable': (.nv11Segment+0x640): undefined reference to $gpu_registers’
test.cu_o: In function $$SymbolTable': (.nv11Segment+0xa0c): undefined reference to blockDim’
test.cu_o: In function $$SymbolTable': (.nv11Segment+0xa18): undefined reference to gridDim’
test.cu_o: In function $$SymbolTable': (.nv11Segment+0xa24): undefined reference to blockIdx’
test.cu_o: In function $$SymbolTable': (.nv11Segment+0xa30): undefined reference to threadIdx’
collect2: ld returned 1 exit status

I found a post here: http://forums.nvidia.com/index.php?showtop…pu_registers%27
which does something similar from fortran (instead of java, like in my case), but I’m not certain how to apply the solution to my case.

when using -G, you have to use nvcc to link as well (with -G)

Oh. Well then that was ridiculusly easy. I had thought for some reason that g++ HAD to be involved because I was using C++ on the host side.

Dropping the -c on the nvcc line pretty much solved it then.

Thanks