c++ - 对静态成员的 undefined reference

标签 c++ undefined-reference cross-compiling

我正在使用交叉编译器。我的代码是:

class WindowsTimer{
public:
  WindowsTimer(){
    _frequency.QuadPart = 0ull;
  } 
private:
  static LARGE_INTEGER _frequency;
};

我收到以下错误:

undefined reference to `WindowsTimer::_frequency'

我也试过改成

LARGE_INTEGER _frequency.QuadPart = 0ull;

static LARGE_INTEGER _frequency.QuadPart = 0ull;

但我仍然遇到错误。

有人知道为什么吗?

最佳答案

您需要在.cpp文件中定义_frequency

LARGE_INTEGER WindowsTimer::_frequency;

关于c++ - 对静态成员的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9110487/

相关文章:

go - 如何在进行交叉编译时切换/选择要使用的代码

c++ - 即使我已经定义了所有功能,但在C++中仍获得对错误的 undefined reference

c++ - 使用按位运算符设置移位位

c++ - 为什么模板只能在头文件中实现?

c++ - 为什么模板只能在头文件中实现?

c++ - undefined reference

c++ - 当静态库不可用时,是否可以从 linux 交叉编译 Windows?

c++ - 字符串列表和字符串

c++ - 编译 proftpd 并在安装目录中包含库拷贝

gcc - mingw 交叉编译错误 - 未定义对 `__mingw_get_msvcrt_handle' 的引用