13

In what way -all_load is different from -ObjC. In my project both behave in same way.

Rajesh
  • 10,318
  • 16
  • 44
  • 64
  • possible duplicate of [What does the -all\_load linker flag do?](http://stackoverflow.com/questions/2906147/what-does-the-all-load-linker-flag-do) – Amar Feb 18 '14 at 05:28
  • 1
    @Amar: Please understand the Question. I m asking the difference between both flags. – Rajesh Feb 18 '14 at 06:06
  • The difference in them is about a bug, which is mentioned in the answer below by Midhun and also in the accepted answer to the question I have linked. Go through the [Apple technical note](https://developer.apple.com/library/mac/qa/qa1490/_index.html) mentioned in that answer. – Amar Feb 18 '14 at 06:09
  • 1
    the Apple technical note mentioned in the previous comment now has it's own revision history that states "Removed discussion of workarounds that are unnecessary in Xcode 4 and later. " and there's no discussion of -all_load if there used to be. – john.k.doe Sep 10 '15 at 00:23

2 Answers2

21

-Objc

This flag causes the linker to load every object file in the library that defines an Objective-C class or category.

-all_load

For 64-bit and iPhone OS applications, there is a linker bug that prevents -ObjC from loading objects files from static libraries that contain only categories and no classes. The workaround is to use the -all_load or -force_load flags. -all_load forces the linker to load all object files from every archive it sees, even those without Objective-C code

Reference Building Objective-C static libraries with categories

Midhun MP
  • 103,496
  • 31
  • 153
  • 200
  • You are right, both flags are used to load all object file. But I m dont know the difference. – Rajesh Feb 18 '14 at 05:17
  • 2
    @user1554347: difference is that `For 64-bit and iPhone OS applications, there is a linker bug that prevents -ObjC from loading objects files from static libraries that contain only categories and no classes. The workaround is to use the -all_load`. There is no other difference, AFAIK. – Midhun MP Feb 18 '14 at 05:26
  • 1
    the reference no longer refers to -all_load, apparently because the problem requiring -all_load has been fixed for a while. – john.k.doe Sep 10 '15 at 00:24
7

From man ld ...

-all_load   Loads all members of static archive libraries.
-ObjC       Loads all members of static archive libraries that implement an Objective-C
              class or category.

-ObjC won't draw in all symbols from all static libraries like -all_load will.

greymouser
  • 3,133
  • 19
  • 22