Deploy Qt C++11 app on Mac OS with older libstdc++

2019-08-06 07:47发布

问题:

When I try to deploy my app on another machine, it fails with dyld/unresolved symbol errors. (Qt static release build, btw.) When I put libstdc++ in the bundle (along with libSystem.B and libobjc.A) and run install_name_tool appropriately, I get new linker errors, for libraries upon which these libraries depend. E.g., libc++.1. I'm really hoping I don't have to manually go through and run install_name_tool on every single library and its children. (Or write my own script, which I don't know how to do.) Is there a better way? This pair (one, two) of questions goes after essentially this question but didn't quite get as far as I did and wasn't resolved in any case.

Here is where I'm at with otool:

$otool -L my_app

/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 41.0.0) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 635.21.0) /System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 55148.6.0) /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 153.0.0) /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1138.51.0) @executable_path/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5) @executable_path//libstdc++.6.dylib (compatibility version 7.0.0, current version 7.17.0) /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1094.0.0) /opt/local/lib/gcc47/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0) @executable_path/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0) @executable_path/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0) /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 53.0.0) /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 833.25.0)

Edit: Here's the initial error message I got, which after making the first round of changes disappeared, to be replaced by a similar message regarding libc++.1:

Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x0000000000000002, 0x0000000000000000 Crashed Thread: 0

Dyld Error Message: Symbol not found: __ZNSt8__detail12__prime_listE Referenced from: /Users/nfoley/Downloads/WaveSorter-mac-1.0.1-static/WaveSorter.app/Contents/MacOS/WaveSorter Expected in: /usr/lib/libstdc++.6.dylib