Sorry if this has come up before (surely it has?).
Problem: Missing libstdc++ symbols when running on 10.5
Description: Using this document as a reference:
I created a new project, command line target, c++ source, and selected a deployment target of 10.5 and Architecture of 32/64 bit and didn't touch any other settings (so base SDK was 10.7). Created a very simple program: #include <string> #include <iostream> #include <ostream>
int main(int argc, char *argv[]) { string foo = argv[0]; foo.insert(1, "otherfoo"); cout << "Hello, World\n" << foo << endl return 0; }
The resultant binary runs fine on 10.6 and 10.7 but not on 10.5:
$ ./sdktest dyld: lazy symbol binding failed: Symbol not found: __ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l Referenced from: /Users/nick/./sdktest Expected in: /usr/lib/libstdc++.6.dylib
dyld: Symbol not found: __ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l Referenced from: /Users/nick/./sdktest Expected in: /usr/lib/libstdc++.6.dylib
Trace/BPT trap
I have a similar problem if I build on 10.6 using xcode 3.2.
Now, I understand that the problem stems from libstdc++ and the version which is shipped with 10.5. But what do people do to avoid this? I can use gcc-4.0 in xcode 3.2.x and the problem goes away, but xcode 4.1 doesn't have that option. Also, I don't see an option in xcode 4.1 to use libc++ ?
Alternatively, I can set a base SDK of 10.5, and it will build, but this obviously locks me out of using 10.6/7 features and checking at runtime (ie weak symbols etc).
Thanks, hopefully there is an easy answer to this question!
Nick
|