未解析的外部符号结构
unresolved external symbol structs
错误LNK2001:未解析的外部符号"public: static int WrappedVector::_N" (?_N@WrappedVector@@2HA)
标题.h
struct WrappedVector
{
static int _N;
double *_x;
};
主.cpp
const int WrappedVector::_N = 3;
我不明白怎么了
只需更改定义
int WrappedVector::_N = 3; // Note no const
查看现场演示1
或声明
struct WrappedVector {
static const int _N;
// ^^^^^
double *_x;
};
查看现场演示2
一贯。
如果您需要后一种形式(static const int
),您也可以直接在声明中初始化它:
struct WrappedVector {
static const int _N = 3;
// ^^^
double *_x;
};
查看现场演示3
相关文章:
- vscode g++链路故障:体系结构x86_64的未定义符号
- 体系结构x86_64的未定义符号:std:terminate(),typeinfo,运算符delete[],运算符new
- OSX clang++:用于 cpp 文件中显式实例化模板的体系结构x86_64的未定义符号
- PCL 出错:体系结构x86_64 @pcl的未定义符号
- clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用) - 体系结构的未定义符号 x86_64:
- 体系结构x86_64的未定义符号:链接器错误
- C++ std::vector<int> 体系结构的未定义符号 x86_64:
- 生成文件:体系结构x86_64的未定义符号
- 标头保护文件中结构的重复符号
- Xcode"体系结构x86_64的未定义符号"
- 快速将无符号字符的向量强制转换为POD结构的向量,反之亦然
- 体系结构x86_64的未定义符号:找不到原因
- 在OSx:ld上使用CMake构建C++项目:找不到体系结构x86_64的符号
- 是否可以将无符号字符数组reinterpret_cast到仅包含C++中无符号字符成员的结构指针
- 体系结构x86_64的未定义符号:c++/ h 文件和 cpp 文件
- boost::任何带有结构体和无符号整数
- 在 c++ 中将结构类型转换为无符号字符*
- 未解析的外部符号结构
- 在库上使用特征板:符号结构查询
- LUA 编译错误与 Visual 2010"外部符号"结构lua_State * __cdecl luaL_newstate(无效)"