String.h来自g ++编译的错误

时间:2011-08-08 14:18:53

标签: c++ string g++ compiler-errors

我不能对g ++

生成的以下C ++错误做出正面或反面
/tmp/ccH0IPVU.o: In function `myAPP::mandatory_bitfield_t::to_s(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
myAPP.cpp:(.text._ZN3myAPP20mandatory_bitfield_t4to_sERSsSs[myAPP::mandatory_bitfield_t::to_s(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)]+0x8c): undefined reference to `myAPP::to_s(unsigned char*, int)'
/tmp/ccH0IPVU.o: In function `myAPP::optional_bitfield_t::to_s(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
myAPP.cpp:(.text._ZN3myAPP19optional_bitfield_t4to_sERSsSs[myAPP::optional_bitfield_t::to_s(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)]+0x8d): undefined reference to `myAPP::to_s(unsigned char*, int)'
collect2: ld returned 1 exit status

是否有人知道这些错误的参考内容以及我如何修复它们?

2 个答案:

答案 0 :(得分:4)

就链接器所知,您忘记包含(编译)myAPP::to_s(unsigned char*, int)的定义。

我只是在翻译错误消息。

干杯&amp;第h

答案 1 :(得分:3)

这实际上是链接器错误。

undefined reference to `myAPP::to_s(unsigned char*, int)

表示您的代码在某处调用 to_s方法,但此方法的主体未包含在传递给链接器的目标文件中。