Use dyld to link in frameworks at runtime. Use ld to make your programs and link archive libraries at build time.

Linker Documentation

Pinned Posts

Posts under Linker tag

162 Posts
Sort by:
Post not yet marked as solved
3 Replies
428 Views
Im having difficulty trying to find C references for the functions and their inputs for the frameworks inside of /System/Library/Frameworks/. Whenever I search it up online I can only get documentation for usage in Swift and Obj-C. I'm trying to link to Carbon.framework in C++ but I can't seem to find any references for the actual funtions I can use. This seems to be across all of the frameworks and the closest I found to a source of refrences was the documentation archive but none of it seems to show the actual references. If anyone has a link to any sort of refrences of any kind then please link them 🥰
Posted
by Garfunkle.
Last updated
.
Post not yet marked as solved
1 Replies
501 Views
I have tried to build the Rust Compiler using XCode 15 and ld. So, I got the linker errors. ld: warning: ignoring file '/private/var/folders/q4/3s60g5510ydbd3qc3p4xflm80000gn/T/rustcms1l5o/symbols.o': found architecture 'arm64e.old', required architecture 'arm64e' My env is Darwin Mac-1702981776371.local 22.6.0 Darwin Kernel Version 22.6.0: Fri Sep 15 13:39:52 PDT 2023; root:xnu-8796.141.3.700.8~1/RELEASE_X86_64 x86_64 Xcode 15.0.1 Build version 15A507 Apple clang version 15.0.0 (clang-1500.0.40.1) Target: x86_64-apple-darwin22.6.0 Thread model: posix InstalledDir: /Applications/Xcode_15.0.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin @(#)PROGRAM:ld PROJECT:dyld-1015.7 BUILD 16:59:22 Oct 1 2023 configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em will use ld-classic for: armv6 armv7 armv7s arm64_32 i386 armv6m armv7k armv7m armv7em LTO support using: LLVM version 15.0.0 (static support for 29, runtime is 29) TAPI support using: Apple TAPI version 15.0.0 (tapi-1500.0.12.3) Library search paths: Framework search paths: Moreover, I cannot reproduce it using Xcode 14.3.1. I don't have any errors when I use LLVM lld. Xcode 14.3.1 Build version 14E300c /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk I tried to compare private headers for binaries using otool -h. They are the same. How can I fix it?
Posted
by arttet.
Last updated
.
Post not yet marked as solved
2 Replies
389 Views
I'm trying to run an app that has a .dylib listed in the configuration of the application as "Embed & Sign" I can confirm it is correctly signed by inspecting the package using codesign -dv --verbose=4 lib_paths.dylib and it gives me the following: Executable=/Users/blablabla/Debug-iphoneos/TestApp.app/Frameworks/lib_paths.dylib Identifier=lib_paths Format=Mach-O thin (arm64) CodeDirectory v=20400 size=784 flags=0x0(none) hashes=16+5 location=embedded VersionPlatform=2 VersionMin=917504 VersionSDK=1049600 Hash type=sha256 size=32 CandidateCDHash sha256=7eaecbb8e00114767c9de0ac9054213620052212 CandidateCDHashFull sha256=7eaecbb8e00114767c9de0ac90542136200522121105dd217b38bd27e1fda4de Hash choices=sha256 CMSDigest=7eaecbb8e00114767c9de0ac90542136200522121105dd217b38bd27e1fda4de CMSDigestType=2 Executable Segment base=0 Executable Segment limit=32768 Executable Segment flags=0x0 Page size=4096 Launch Constraints: None CDHash=7eaecbb8e00114767c9de0ac9054213620052212 Signature size=4795 Authority=Apple Development: myemail@address.com (XXXXXXXXX) Authority=Apple Worldwide Developer Relations Certification Authority Authority=Apple Root CA Signed Time=13 Dec 2023 at 21:39:28 Info.plist=not bound TeamIdentifier=XXXXXXXXXXX Sealed Resources=none Internal requirements count=1 size=180 But when trying to run the application, I am getting the following error: Referenced from: '/private/var/containers/Bundle/Application/3142F1F2-547B-41B5-8EF4-239F4EAD2A4F/TestApp.app/FSVTestApp' Reason: tried: '/usr/lib/system/introspection/lib_paths.dylib' (no such file), '/usr/lib/swift/lib_paths.dylib' (no such file), '/private/var/containers/Bundle/Application/3142F1F2-547B-41B5-8EF4-239F4EAD2A4F/TestApp.app/Frameworks/lib_paths.dylib' (code signature invalid (errno=1) sliceOffset=0x00000000, codeBlobOffset=0x0000C5E0, codeBlobSize=0x00004B50 for '/private/var/containers/Bundle/Application/3142F1F2-547B-41B5-8EF4-239F4EAD2A4F/TestApp.app/Frameworks/lib_paths.dylib'), Note that I enabled the "Automatically manage signing" option, and using a Personal Team. This seems to work fine for the application itself (otherwise it wouldnt even try to load the dylib). What is going on ?
Posted Last updated
.
Post not yet marked as solved
2 Replies
471 Views
xcode :Version 15.0.1 (15A507) MACOS:13.6.1 (22G313) thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0) frame #0: 0x0000000000000000 frame #1: 0x000000010482ec60 FUSTAKitOUTLINED_FUNCTION_3 + 580 frame #2: 0x0000000104430810 dyldImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&) + 424 frame #3: 0x0000000104430bd8 dyldImageLoaderMachO::doInitialization(ImageLoader::LinkContext const&) + 52 frame #4: 0x000000010442b600 dyldImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, char const*, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 536 frame #5: 0x000000010442b56c dyldImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, char const*, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 388 frame #6: 0x0000000104429878 dyldImageLoader::processInitializers(ImageLoader::LinkContext const&, unsigned int, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 184 frame #7: 0x0000000104429940 dyldImageLoader::runInitializers(ImageLoader::LinkContext const&, ImageLoader::InitializerTimingList&) + 92 frame #8: 0x000000010441a6d8 dylddyld::initializeMainExecutable() + 216 frame #9: 0x000000010441f928 dylddyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) + 5216 frame #10: 0x0000000104419208 dylddyldbootstrap::start(dyld3::MachOLoaded const*, int, char const**, dyld3::MachOLoaded const*, unsigned long*) + 396 frame #11: 0x0000000104419038 dyld`_dyld_start + 56 when I run a Test app(Just create with xcode Version 15.0.1 (15A507),without any extra code) depency FUSTAKit.framework packed by xcode Version 15.0.1 (15A507), i find this error。 but used xcode 14.2 pack FUSTA Kit.framework , everything is normal 。
Posted Last updated
.
Post not yet marked as solved
1 Replies
425 Views
I am trying to add an Apple Watch companion app to my iPhone app. I have no experience with Apple Watch at all, so I followed the Apple instructions as described on https://developer.apple.com/tutorials/swiftui/creating-a-watchos-app I followed that instruction to the letter, and did not add anything to it, and now have two targets in the project: the original iPhone target, and the Apple Watch target. When I try to build the Watch app, I get the following linker error: error: Build input file cannot be found: '/usr/lib/libobjc.A.dylib'. Did you forget to declare this file as an output of a script phase or custom build rule which produces it? The linker command has the following argument on it: -weak_library /usr/lib/libobjc.A.dylib The "Link binary with libraries" option of the "Build Phases" of the Apple Watch target does not have any libraries specified. Does anybody know what the libobjc library is, and what it is used for? Where is this linker flag configured? How can I make this work? EDIT: The -weak_library /usr/lib/libobjc.A.dylib is configured in the Project Build Settings, "Other Linker Flags". It seems to be a basic necessity that was already there before I added the Watch target. When I remove it, I get "Undefined symbol: _main" errors. So it seems to be something fundamental that is required. The question is now why it is not found by the linker. If it matters, the iPhone app has always been Objective-C, but I'd like to start with Swift for the Apple Watch app, so have chosen to create that as a Swift app.
Posted
by baraupp.
Last updated
.
Post marked as solved
2 Replies
673 Views
Hello, Upgrading to Xcode 15 and building for testing ends up with errors. Note: Xcode 15.1 beta3 & 15.0.1 - normal debug build works Xcode 15.1 beta3 & 15.0.1 - unit test build fails Xcode 14.3.1 - both builds work Using Swift Package Manager to add the packages Error: ld: Undefined symbols: (extension in PackageX):...-> SwiftUI.Font, referenced from: PackageY... in PackageY.o (extension in PackageX)... ... clang: error: linker command failed with exit code 1 (use -v to see invocation) What I've tried: clean up project remove & add involved packages adding 'other linker flags' to the main target build settings such as -ld64, -ld_classic What should I update to work in Xcode 15? Thank you.
Posted
by polikw.
Last updated
.
Post not yet marked as solved
2 Replies
425 Views
Hello team, We have some time experiencing this crash in our application, this only happens on iOS 13.x versions, and it's working perfectly on iOS 12.x, iOS 14.x and upper. To compile the application we are using Xcode 14.2.0, but I read in other threads that the issue should be fixed by using Xcode 14.3.1: https://developer.apple.com/forums/thread/727680?answerId=753414022#753414022 So I tested again by compiling the app with that version but the result is the same, the app crashes immediately. I have also tried to compile it with Xcode 15.x but with no results. This is the crash log: {"app_name":"Retail-Beta","timestamp":"2023-11-20 22:25:22.00 +0000","app_version":"1.29.0","slice_uuid":"fe183a9d-16be-355d-b7dc-61ec3ddc8537","adam_id":0,"build_version":"1","bundleID":"com.inditex.appgeret.dev","share_with_app_devs":0,"is_first_party":0,"bug_type":"109","os_version":"iPhone OS 13.4.1 (17E8258)","incident_id":"791A392C-B9FB-44A1-98FF-C7361A37AFC6","name":"Retail-Beta"} Incident Identifier: 791A392C-B9FB-44A1-98FF-C7361A37AFC6 CrashReporter Key: 6af5c2f0a1a67986c7759373f00ff1e4c8cc596b Hardware Model: iPhone12,8 Process: Retail-Beta [1680] Path: /private/var/containers/Bundle/Application/82DCA6DB-3F0D-4230-8011-5CF9CE678B4B/Retail-Beta.app/Retail-Beta Identifier: com.....appgeret.dev Version: 1 (1.29.0) Code Type: ARM-64 (Native) Role: Foreground Parent Process: launchd [1] Coalition: com.....appgeret.dev [1827] Date/Time: 2023-11-20 22:25:22.1498 +0000 Launch Time: 2023-11-20 22:25:21.8010 +0000 OS Version: iPhone OS 13.4.1 (17E8258) Release Type: User Baseband Version: 1.05.28 Report Version: 104 Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY Termination Description: DYLD, Assertion failed: (gotLocation), function applyFixupsToImage_block_invoke_3, file /Library/Caches/com.apple.xbs/Sources/dyld/dyld-750.4.2/dyld3/Loading.cpp, line 779. Highlighted by Thread: 0 Backtrace not available Unknown thread crashed with ARM Thread State (64-bit): x0: 0x0000000000000006 x1: 0x0000000000000009 x2: 0x000000016d8b41a0 x3: 0x0000000000000014 x4: 0x000000016d8b3da0 x5: 0x0000000000000000 x6: 0x000000016d8b4b30 x7: 0x000000016d8b4c48 x8: 0x0000000000000020 x9: 0x0000000000000009 x10: 0x2e676e6964616f4c x11: 0x6e696c202c707063 x12: 0x2f33646c79642f32 x13: 0x2e676e6964616f4c x14: 0x6e696c202c707063 x15: 0x000a2e3937372065 x16: 0x0000000000000209 x17: 0x000000010349f510 x18: 0x0000000000000000 x19: 0x0000000000000000 x20: 0x000000016d8b3da0 x21: 0x0000000000000014 x22: 0x000000016d8b41a0 x23: 0x0000000000000009 x24: 0x0000000000000006 x25: 0x0000000000000160 x26: 0x000000000000035e x27: 0x000000010333a62c x28: 0x00000000000e69b0 fp: 0x000000016d8b3d70 lr: 0x00000001034ac66c sp: 0x000000016d8b3d30 pc: 0x00000001034a4f30 cpsr: 0x40000000 esr: 0x00000000 Address size fault Binary images description not available Error Formulating Crash Report: Failed to create CSSymbolicatorRef - corpse still valid ¯\_(ツ)_/¯ EOF Could you please help us to understand what it's happening here? Are we missing something or could we are doing something wrong from our side? We are running low on options or ideas. Thanks in advance, Paul
Posted Last updated
.
Post marked as solved
1 Replies
349 Views
I'm developing a cross plaform application and am using Xcode to build the MacOS executable. I have it building and running on my machine with the 3rd party dynamic libraries placed in /opt/homebrew (as installed by brew), but obviously when I move to another machine it doesn't work Within Xcode i've added my 3rd party dependencies to Frameworks, Libraries and Embedded content within my target. After the build, these are copied to Contents/Frameworks as I expect but the executable is not linked to these dylibs but the ones in /opt/homebrew I read around the forums here and set dynamic library install name = @rpath/$(EXECUTABLE_PATH) and runpath search path = @executable_path/../Frameworks but this doesn't fix my issue While I'm confident working with other platforms, this is my first time developing for MacOS, I've only been a Mac user for ten months so i know this is an easy fix its just something I'm missing
Posted
by aidenj.
Last updated
.
Post not yet marked as solved
0 Replies
390 Views
I wanna test my SwiftUI app on TestFlight and then I'll release the app on App Store. However, I get an error during Distribute App processing. I do Archive and Distribute App with TestFlight & App Store option and then I get "Assert Validation Failed" see below. When I check output of compiling, I see a few warnings. You can see below. I totally do not understand what problem is. How can I solve this problem ?
Posted Last updated
.
Post not yet marked as solved
2 Replies
1k Views
dyld: Symbol not found: __ZTTNSt3__114basic_ofstreamIcNS_11char_traitsIcEEEE Referenced from: /private/var/containers/Bundle/Application/19315D00-BA14-46B0-83BD-0961BBFFC9B8/VBell.app/VBell Expected in: /usr/lib/libc++.1.dylib in /private/var/containers/Bundle/Application/19315D00-BA14-46B0-83BD-0961BBFFC9B8/VBell.app/VBell Who knows how to solve this problem?
Posted
by wzbin.
Last updated
.
Post not yet marked as solved
8 Replies
593 Views
When I'm running my Mac app in the Xcode debugger, and it launches a helper app, the helper crashes with a dyld error. This does not happen if I am not debugging. Termination Reason: Namespace DYLD, Code 1 Library missing Library not loaded: @rpath/Cal3D.framework/Versions/A/Cal3D Referenced from: <3C1A67BA-5545-31A2-86C5-77104B0194FE> /Volumes/VOLUME/*/SBEngineLib4.framework/Versions/A/SBEngineLib4 The frameworks SBEngineLib4.framework and Cal3D.framework exist in the main app. The helper app does not contain any frameworks, but does contain dylib versions of those frameworks, which I suppose is confusing things somehow.
Posted
by JWWalker.
Last updated
.
Post not yet marked as solved
0 Replies
489 Views
I have an iOS app target with a framework dependency and want to merge that framework by setting MERGED_BINARY_TYPE to automatic in the app target's build settings. It all works fine until I add a (non-private) UIHostingController to the framework target. When I do this it crashes on startup with this message: dyld[15894]: Symbol not found: _OBJC_CLASS_$__TtC5Frame4MyVC. Xcode 15.1b3 Reported as bug via Feedback Assistant: FB13379276
Posted
by peweone.
Last updated
.
Post not yet marked as solved
5 Replies
458 Views
I'm trying to use tapi to generate a .tbd for a multi-arch dynamic library. The dynamic library has LC_UUIDs for both architectures, but the generated .tbd does not have a uuids section. I have tried generating .tbd versions 2, 3, and 4. (Which version should I use if I want to support older macOS releases?) I'm using the command tools from Xcode 15.0.1 on macOS 14.1 on arm64.
Posted
by cbfiddle.
Last updated
.
Post not yet marked as solved
1 Replies
791 Views
Hello all, we have ran into a problem building our test target that only occurs in Xcode 15. Our team has an SPM package that we use for shared code across our apps. This SPM package also has a dynamically linked target that contains utilities for testing. Within our app we link this test utilities library via Build Phases -> Link Binary with Libraries. On Xcode < 15 we have no problem resolving this library within our test target but on 15 we get a linking error if we try and and link it in the same way. If we remove this library from Build Phases -> Link Binary with Libraries then the linking error goes away, though of course then we will get errors as this library is still used within the XCTests of our test target. This is a simplified snippet of what our Package.swift looks like for our Swift Package let package = Package( name: "Library", platforms: [ .iOS(.v15) ], products: [ .library( name: "Library", targets: ["Library"] ), .library( name: "LibraryTestUtilities", type: .dynamic, targets: ["LibraryTestUtilities"] ) ], dependencies: [ // Dependencies declare other packages that this package depends on. ], targets: [ .target( name: "Library", dependencies: [ // Dependencies ]) , .target( name: "LibraryTestUtilities", dependencies: [ "Library" ]), .testTarget( name: "LibraryTests", dependencies: ["Library", "LibraryTestUtilities"]), ] ) I have tried to use the linker flags -ld_classic and -ld64 to no avail and I'm not sure where to go from here. It's not exactly obvious what linking change in Xcode 15 is resulting in the failure to resolve this library. We would appreciate any help on this matter, thanks!
Posted
by artclark.
Last updated
.
Post not yet marked as solved
1 Replies
470 Views
Intro I'm trying to determine whether Xcode's new Mergeable Libraries feature can remove duplicated symbols in a scenario where an app links to two dynamic frameworks which both link to the same static library, as follows: |--App |--DynamicFramework1 |--StaticLibrary |--DynamicFramework2 |--StaticLibrary <- the same library that DynamicFramework1 links to Project setup Here are some details about the app's structure: The static library is named StaticLibrary. It: Contains a single Objective-C class named SLClass1 The first dynamic framework target is named DynamicFramework1. It: Contains a single Objective-C class named DF1Class1 that calls into SLClass1; and Has a MERGEABLE_LIBRARY build setting value of YES. The second dynamic framework target is named DynamicFramework2. It: Contains a single Objective-C class named DF2Class1 that calls into SLClass1; and Has a MERGEABLE_LIBRARY build setting value of YES. The app target is named App. It: Contains a single Swift class named ViewController that calls into the DF1Class1 and DF2Class1 classes; and Has a MERGED_BINARY_TYPE build setting value of Automatic. (1) I've created a minimal Xcode project here that has the above structure. Expected result The merged app binary, when built it in Release mode, contains the symbols for DF1Class1, DF2Class1 and SLClass1 directly within it and it contains only one instance of each of these symbols (i.e. no duplicates). I am basing this expectation on the Benefits of mergeable libraries section of the Meet mergeable libraries talk from WWDC 2023 where the speaker said: When merging, the linker can de-duplicate content, such as strings, across all libraries. For instance, it removes redundant symbol references, Objective-C selectors, and objc_msgsend stubs. Actual result The merged app binary, when built it in Release mode, contains the symbols for DF1Class1, DF2Class1 and SLClass1 directly within it but it contains two instances of SLClass1's symbols (i.e. it contains duplicates). (2) My Question Have I missed something in the app's build settings or have I misunderstood the capability of Mergeable Libraries? Can I get the Xcode linker to deduplicate symbols in the app's merged binary? Footnotes I have tried with a MERGED_BINARY_TYPE build setting value of Manual also but the result is the same. I have validated this by running the nm command on the app's executable file and inspecting the output.
Posted
by ale-gen.
Last updated
.
Post not yet marked as solved
1 Replies
519 Views
The following is occurring when linking a release version of our test suite. 0 0x102d82f9c __assert_rtn + 72 1 0x102d36e08 mach_o::Symbol ld::Layout::symbolForAtom<ld::LinkedAtomPlacement const>(ld::Atom const*, CString, ld::LinkedAtomPlacement const&, ld::DylibMapping const*, unsigned long long) const + 2120 2 0x102d36ff8 void dispatchForEach<ld::AtomAndName const, void ld::buildSymbolTableld::LinkedAtomPlacement(ld::SymbolTableLayout&, ld::Layout const&, ld::Options const&, ld::AtomSymbolPartition const&, ld::LinkedAtomPlacement const&, ld::DylibMapping const*, unsigned long long, bool, bool)::'lambda1'(unsigned long, ld::AtomAndName const&)>(std::__1::span<ld::LinkedAtomPlacement, 18446744073709551615ul>, unsigned long, void ld::buildSymbolTableld::LinkedAtomPlacement(ld::SymbolTableLayout&, ld::Layout const&, ld::Options const&, ld::AtomSymbolPartition const&, ld::LinkedAtomPlacement const&, ld::DylibMapping const*, unsigned long long, bool, bool)::'lambda1'(unsigned long, ld::AtomAndName const&))::'lambda'(unsigned long)::operator()(unsigned long) const + 152 3 0x102d3f17c ld::LayoutExecutable::writeToFile(char const*) + 5004 4 0x102cf362c main + 9604 ld: Assertion failed: (0 && "lto symbol should not be in layout"), function symbolForAtom, file Layout.cpp, line 1447.
Posted
by zhattis4.
Last updated
.
Post marked as solved
1 Replies
1.5k Views
I am writing to report an issue that I've encountered while using Xcode 15 to compile an iOS 17 project. The error message I received is as follows: ld: Assertion failed: (false && "compact unwind compressed function offset doesn't fit in 24 bits"), function operator(), file Layout.cpp, line 5758. At present, the exposure path of this problem seems to be here: "Xcode.app-strings/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin /ld". I want to bring to your attention that this issue has been persistent from beta 6 to the official release of Xcode 15. I have already submitted a bug report with the identifier FB13321572. I am keen to leverage the new feature "ld-prime" and would greatly appreciate your guidance and support in finding an elegant solution to address this problem.(The implication is that I don't really want to continue using ld64 linker ...lol) Thanks
Posted Last updated
.
Post marked as solved
1 Replies
616 Views
Hello, I have create a dynamic library with gcc: gcc -dynamiclib liblib1.c -o liblib1.dylib I have create a binary which needs this dynamic library: gcc -L./ -llib1 test.c -o test I have looked at mach-o commands in test binary. I have seen the library is loaded with LC_LOAD_WEAK_DYLIB. How can i load the library with LC_LOAD_DYLIB instead of LC_LOAD_WEAK_DYLIB ? And i have a second question: Is it possible to compile the binary with a static linking of the library ? I have tried with -static option, like i do on Linux but it does not work on macOS and i don't understand why... Thanks
Posted Last updated
.
Post not yet marked as solved
3 Replies
713 Views
I am not able to install after downloading command line tools 14.3.1 in macOS Sonoma 14.0. The error message is the following "Command Line Tools can't be installed on this disk (Macintosh HD). The version of macOS is too new." What should I do to install it ? And what to do after that so that 14.3.1 version is used by Mac instead of 15.0 version of command line tools ?
Posted
by AlokKT105.
Last updated
.