Mac 10.7 / 10.8上的C ++运行时错误

时间:2012-10-01 20:18:34

标签: c++ eclipse macos dylib

我在Mac OS 10.7和10.8上使用Eclipse,GCC 4.8和构建C ++项目。在大多数情况下,除了某些特定功能外,项目的构建和运行都是正确的。例如:

int main( int argc, char ** argv ) {
    string a = "test";
    string b = "-bla";
    string c;
    c = a + b;
    return 0;
}

编译成功:

  

构建项目的调试工作**

     

make all building file:../ working.cpp Invoking:GCC C ++ Compiler 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构建目标:工作调用:MacOS X C ++链接器   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;

程序运行完美。

任何人对此处发生的事情都有任何想法?感谢

0 个答案:

没有答案