Using the new Xcode 8 GM build on the GM of macOS Sierra, I've recompiled a Qt 5.7 C++ project and I'm getting the following error message when trying to launch the app:
Reason: no suitable image found. Did find:
/path/to/my/lib/libio_core.dylib:
malformed mach-o image: symbol table underruns __LINKEDIT
This doesn't occur on debug builds, only release. Does anyone have an idea as to what this means and how to go about fixing it?
Update:
This actually has nothing to do with Xcode 8. Building the same code with Xcode 7.3.1 results in the same outcome. It seems some apps that ran just fine on El Capitan won't run on Sierra and fail with the above error.
Update 2: Details about the symbol table in my binary:
Load command 5
cmd LC_SYMTAB
cmdsize 24
symoff 0
nsyms 0
stroff 12760
strsize 8
Turns out this was caused by Qt. Qt 5.7.0 calls strip with no arguments when performing the install task on libs. With macOS Sierra this results in a dylib with an empty symtab.
This bug will be fixed in Qt 5.7.1. In the meantime, just make sure you call strip with -S -x for dynamic libraries.
I am seeing a similar error and I have just figured it out in my case. I hope what I found will help you too.
So, basically, as far as I can tell, this happens when your binary has an empty symbol table (there might be other cases, though). You can check this by running objdump -private-headers <library>:
<...>
Load command 4
cmd LC_SYMTAB
cmdsize 24
symoff 0
nsyms 0 <-- no symbols, oops
stroff 4104
strsize 8
<...>
Linker believes that if the symbol table is empty (nsyms 0) it is ok to say that the offset of the table into the file is zero (symoff 0). So, strictly speaking, it claims that the table starts right at the beginning of the binary.
Apparently, the new version of dyld from 10.12 Sierra performs a check that previous versions did not perform: it makes sure that the symbols table is entirely within the __LINKEDIT segment. Well, in our case the symbol table clearly violates this constraint and dyld does not care that it is empty.
I would call this an Apple’s bug: their linker creates malformed binaries and doesn’t bother to even issue a warning. If I were Apple, I would modify the condition in dyld to ignore the symbol table constraint if the symbol table is empty.
There is only one workaround I can see: add a dummy symbol to your reexport library.
Related
I receive the error:
.../Base.lproj/MainMenu.xib Failed to render instance of : dlopen(....app, 0x0001): tried: '/...' (no such file), '....app' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS....app' (no such file), '....app' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))`
when loading my .xib. Where <MyView> stands for the name of my derivated NSView and the ... for my application name.
There are quite a number of reports with this or a similar issues when the 1st M1 processors were on the market as:
(Xcode 12 Apple M1 arm64 - Designable error: "wrong architecture") or
(IBDesignable Build Failed) and more. Most of them add some pathes to the LD_RUNPATH_SEARCH_PATHS under "Linking".
None of the solutions given there were helpful for me, but I found a link where you could change the arch under which the Terminal should run.
see
Partly solved:
Now after opening my .proj file and when I receive this error, I open the Terminal.app, switch it to Intel and then back to Arm (leaving the terminal window open) and voila the IB preview displays correctly. See result here
Concerning XCode this is a regression, since under Intel Xcode 11 this always was working correctly.
Anybody knows, what is happening or how to avoid this inconvenience?
the formatting now is not ok. The error message ends with
.../Base.lproj/MainMenu.xib Failed to render instance of :
dlopen(....app, 0x0001): tried: '/...' (no such file), '....app'
(mach-o file, but is an incompatible architecture (have 'x86_64', need
'arm64')), '/System/Volumes/Preboot/Cryptexes/OS....app' (no such
file), '....app' (mach-o file, but is an incompatible architecture
(have 'x86_64', need 'arm64'))
I'm trying to run an existing application to see how well it works with the latest Xcode beta and to try to use SwiftUI in an existing project. When I run the project on Simulator I get the following run-time crash:
dyld: Symbol not found: __ZTISt11logic_error
Referenced from: /Users/lucas/Library/Developer/CoreSimulator/Devices/224333CF-0388-4F57-9633-6CAB37B33510/data/Containers/Bundle/Application/<Guid>/<AppName>.app/<AppName>
Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/AudioToolbox.framework/AudioToolbox
in /Users/<name>/Library/Developer/CoreSimulator/Devices/224333CF-0388-4F57-9633-6CAB37B33510/data/Containers/Bundle/Application/<Guid>/<AppName>.app/<AppName>
Setting everything to iOS 13 made the error go away but that won't work in the near future. Also tried to remove anything related to Audio and AV frameworks but that didn't help.
Apparently same bug, but with different symbol:
dyld: Symbol not found: __ZTISt9bad_alloc
Referenced from: <bla-bla-bla>
Expected in: /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 12.1.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/AudioToolbox.framework/AudioToolbox
in <bla-bla-bla>
#Jeremy's answer worked for me. To help find it, the file is at
/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/AudioToolbox.framework/AudioToolbox.tbd
and the lines you take out are:
weak-def-symbols: [ __ZTI11CAException, __ZTIN8DSPGraph9ExceptionE, __ZTINSt3__112bad_weak_ptrE,
__ZTINSt3__117bad_function_callE, __ZTISt11logic_error, __ZTISt12length_error,
__ZTISt12out_of_range, __ZTISt13runtime_error, __ZTISt16invalid_argument,
__ZTISt18bad_variant_access, __ZTISt8bad_cast, __ZTISt9bad_alloc,
__ZTISt9exception, __ZTS11CAException, __ZTSN8DSPGraph9ExceptionE,
__ZTSNSt3__112bad_weak_ptrE, __ZTSNSt3__117bad_function_callE,
__ZTSSt11logic_error, __ZTSSt12length_error, __ZTSSt12out_of_range,
__ZTSSt13runtime_error, __ZTSSt16invalid_argument, __ZTSSt18bad_variant_access,
__ZTSSt8bad_cast, __ZTSSt9bad_alloc, __ZTSSt9exception ]
This is a bug in the iOS 13 Beta SDK. You can hack around it by editing the AudioToolbox.tbd file within the SDK to remove the __ZTISt11logic_error (et al) symbols that shouldn't have been exported from there, or you can edit your link line to include -lc++ before -framework AudioToolbox (such that the static linker uses the correct references in libc++ rather than the once that were incorrectly referenced from AudioToolbox).
Or you can wait for a future beta with the fix ;)
I had crash with quite same error:
dyld: Symbol not found: __ZTISt11logic_error
Referenced from: <bla-bla-bla>
Expected in: /System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox
in <bla-bla-bla>
But I faced it when I was compiling own C++ project in Clion, so nothing linked with Simulator or iOs.
At that time I had XCode 10.2.1. I have tried multiple stuff to fix this crash, but nothing helped.
Luckily I found this post, so I downgraded my XCode to 10.1 and it's Command Line Tools. And it helped me!
So, even if my advice may not help with XCode 11 beta, I hope it can help other developers with the same error as you have.
This is an Xcode bug, but with a work-around. In your target's "Frameworks Libraries & Embedded Content" section, add libc++.tbd and make sure it's the at the top of the list. That should be all your need.
After some editing my Xcode 5.1.0 source files I suddenly get this linker error:
0 0x1059b5f93 __assert_rtn + 144
1 0x105a1d7f5 ld::tool::OutputFile::compressedOrdinalForAtom(ld::Atom const*) + 281
2 0x105a1e469 ld::tool::OutputFile::addDyldInfo(ld::Internal&, ld::Internal::FinalSection*, ld::Atom const*, ld::Fixup*, ld::Fixup*, ld::Fixup*, ld::Atom const*, ld::Atom const*, unsigned long long, unsigned long long) + 2261
3 0x105a14496 ld::tool::OutputFile::generateLinkEditInfo(ld::Internal&) + 1322
4 0x105a0f952 ld::tool::OutputFile::write(ld::Internal&) + 116
5 0x1059b6c40 main + 1012
A linker snapshot was created at:
/tmp/keytech PLM-2014-03-05-101905.ld-snapshot
ld: Assertion failed: (0 && "dylib not assigned ordinal"), function compressedOrdinalForAtom, file /SourceCache/ld64/ld64-236.3/src/ld/OutputFile.cpp, line 3454.
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have absolute no idea what this means?
I already tried to:
Delete the derived data folder
Clean Files and build files
Cosed and reopen Xcode
Made sure no Linker Optimizer are active: No dead Code Stripping, No Link Time Optimization.
I also have excluded some of my latest changed code. With no result.
Googleing the error did not find any useful information.
Does anybody have an idea?
In my case the linker error was gone after I switched in the Build Settings "OSX Deployment Target" from "10.7" to "10.8".
This looks like an open bug at llvm, which has been passed to Apple (and is therefore in a black hole).
No other information appears to be available so you need to step back in your development (via git) to figure out what triggered it, and then contribute any information you glean to llvm (via the bug reporter).
Not an answer, but I don't believe there is an answer to this issue...
I had this bug for a while.
The way I eventually fixed it was by trying to compile in Xcode 4.6
Once I tweaked my project to compile there, I got the much more helpful error:
Undefined symbols for architecture x86_64:
"_Gestalt", referenced from:
_GetOS in main.o
that led me to adding the coreservices framework (which was required by a third party framework I was adding), and from there, my project compiled just fine on xcode 5 & 6
so - that may not be the framework you need, but the approach may help you.
I ran into this too, but only for release builds. By process of elimination, I was able to get the release builds working by setting the Link-Time Optimization build setting to NO (LLVM_LTO = NO) under Apple LLVM – Code Generation.
I have successfully built and installed latest binutils-2.22 on Solaris 10.
But when I try to use the installed programs such as ld and or I get a run-time error:
ld.so.1: ld: fatal: relocation error: file /home/pernord/alt/bin/ld: symbol __clz_tab: referenced symbol not found
I have search extensively for the error but all the hits seems unrelated to my problem.
From what I have read __clz_tab seems related to 'libgcc`.
At least libgcc contains the symbol clz.
strings /lib/*/libgcc* | grep clz
Ideas anyone?
__clz_tab is a table in libgcc used to implement a CLZ ("count leading zeros") function.
Do your binutils executables depend on libgcc_s.so? What does ldd /home/pernord/alt/bin/ld show?
If libgcc_s.so isn't in your library search path you might need to use crle(1) to add it.
I linked my MacOS project to the EDMessage.framework. Now I get this error:
Apple Mach-O Linker (Id) Error:
in /Users/.../EDMessage 17/EDCommon.framework/EDCommon, truncated fat file. Slice from 847872 to 1189136 is past end of file with length 1048576 for architecture x86_64
Any idea how to resolve this?
(I using Xcode 4.3.2)
A similar issue is being discussed on the "official" forum: http://www.mulle-kybernetik.com/forum/viewtopic.php?f=5&t=273