我正在使用 Eclipse、GCC 4.8 并在 Mac OS 10.7 和 10.8 上构建 C++ 项目。在大多数情况下,项目构建和运行正常,除了一些特定的功能。例如:
int main( int argc, char ** argv ) {
string a = "test";
string b = "-bla";
string c;
c = a + b;
return 0;
}
编译成功:
为项目工作构建配置调试**
生成所有构建文件:../working.cpp 调用:GCC C++ 编译器 g++ -O0 -g3 -Wall -c -fmessage-length=0 -std=c++11 -MMD -MP -MF"working.d" - MT"working.d" -o "working.o" "../working.cpp" 完成构建:../working.cpp 构建目标:Working 调用:MacOS X C++ Linker g++ -o "Working" ./working. o 完成的建筑目标:工作
构建完成**
但是,我收到了这个运行时错误:
dyld: lazy symbol binding failed: Symbol not found: __ZNSsaSEOSs
Referenced from: /Volumes/Macintosh HD/Users/zeroliu/Study/CPP/Working/Debug/Working
Expected in: /usr/lib/libstdc++.6.dylib
dyld: Symbol not found: __ZNSsaSEOSs
Referenced from: /Volumes/Macintosh HD/Users/zeroliu/Study/CPP/Working/Debug/Working
Expected in: /usr/lib/libstdc++.6.dylib
我发现错误来自
string c;
c = a + b;
有趣的是,如果我进行以下更改:
string c = a+b;
或者
c = a;
程序运行完美。
有人对这里发生的事情有任何想法吗?谢谢