I got a problem when I try to compile a simple code there are C++ and Cuda code compile in a separated way.
Here's my code
main.cpp:
#include "file.cuh"
int main( void )
{
test();
return 0;
}
file.cuh:
void test( void );
file.cu:
#include <cuda.h>
#include <cuda_runtime.h>
#include <cstdio>
#include "file.cuh"
__global__ void printId( void )
{
printf("Hello from block %d
", blockIdx.x);
}
__global__ void DynPara( void )
{
dim3 grid( 2, 1, 1 );
dim3 block( 1, 1, 1 );
printId<<< grid, block >>>();
}
void test( void )
{
dim3 grid( 1, 1, 1 );
dim3 block( 1, 1, 1 );
dynPara<<< grid, block >>>();
}
I compile with:
nvcc -arch=sm_35 -lcudadevrt -rdc=true -c file.cu
g++ file.o main.cpp -L<path> -lcudart
And here's the error while compiling:
file.o: In function `__sti____cudaRegisterAll_39_tmpxft_00005b2f_00000000_6_file_cpp1_ii_99181f96()':
tmpxft_00005b2f_00000000-3_file.cudafe1.cpp:(.text+0x1cd): undefined reference to `__cudaRegisterLinkedBinary_39_tmpxft_00005b2f_00000000_6_file_cpp1_ii_99181f96'
os: Red Hat
card: K20x
Any idea?
Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…