nvccを使用して次の問題が発生しました。別のコンパイルを使用して(最終的にcmake__device__ __constant__ (extern) type1<type2> var[length]
で実行しました)、配列の宣言で問題が発生しました。
これが私のヘッダーです:
#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
そして彼女の私の.cuファイル:
#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];
}
}
}
}
中間の個別のコンパイル手順で次のエラーが発生します。
nvlink error : Undefined reference to '_ZN12NameSpace115NameSpace29Constants17arrayE'
これは、.cuファイルへのアクセスが原因です。提案をありがとう。