i got the following problem using nvcc.
I use separate compilation (finally got it running with cmake) and got a problem with the declaration of a __device__ __constant__ (extern) type1<type2> var[length]
array.
Here is my header:
#include <type.h>
#include <type2.h>
#ifndef GUARD_H_
#define GUARD_H_
namespace NameSpace1{
namespace NameSpace2{
namespace Constants{
__device__ __constant__ extern Type1<Type2> array[10];
__device__ Type1<Type2> accessConstantX(size_t index);
}
}
}
#endif
And her my .cu-file:
#include <header.h>
#include <assert.h>
namespace NameSpace1{
namespace NameSpace2{
namespace Constants{
__device__ Type1<Type2> accessConstantX(size_t index){
assert(index <= 9);
return array[index];
}
}
}
}
I get the following error from intermediate separate compilation step:
nvlink error : Undefined reference to '_ZN12NameSpace115NameSpace29Constants17arrayE'
This results from the access in the .cu-file. Thanks for suggestions.