【问题标题】:"undefined reference" (works on linux, but not with cygwin on windows) [duplicate]“未定义的参考”(适用于linux,但不适用于windows上的cygwin)[重复]
【发布时间】:2012-12-15 17:32:25
【问题描述】:

可能重复:
gcc linker errors on fedora: undefined reference

由于我在使用 VC++ 时遇到了问题(gcc 不会发生函数重载,因为我的项目合作伙伴正在 Linux 上编程),我在 cygwin 上切换到 gcc,但我无法让程序运行这里也是(他能够毫无问题地编译相同的代码)

我正在尝试用

编译
$ gcc -I D:/Programme/Boost_Library/boost_1_51 ABI_new.cpp -o ABI

然后我得到了大量这样的错误:

/tmp/ccO4eSA2.o:ABI_new.cpp:(.text+0xd): undefined reference to ´std::basic_string<char, std::char_traits<char>, std::allocator<char> >::size() const'
    /tmp/ccO4eSA2.o:ABI_new.cpp:(.text+0x60): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned int) const'
    /tmp/ccO4eSA2.o:ABI_new.cpp:(.text+0x9f): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned int) const'
    /tmp/ccO4eSA2.o:ABI_new.cpp:(.text+0xce): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned int) const'

我不确定这是否与程序显然无法读取输入文件有关(由退出状态指示),但我不知道为什么这也不起作用,因为- 再次 - 我的同事对完全相同的代码没有任何问题。

如果有任何提示,我将不胜感激。

【问题讨论】:

  • 尝试使用g++ 而不是gcc 进行编译。后者可能不知道 C++ 标准库。

标签: c++ boost reference cygwin undefined


【解决方案1】:

尝试使用g++ 而不是gcc 进行编译。后者可能不知道 C++ 标准库,并且没有指示链接器链接它。

【讨论】:

  • 非常感谢。多么愚蠢的错误^^
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-09
  • 1970-01-01
  • 2015-10-28
  • 2011-10-27
  • 1970-01-01
  • 2013-12-11
相关资源
最近更新 更多