Other Linker Flags

Options
peteo
edited September 2011 in Native
What is the role of Other Linker Flags?
like this:

../../Common-objc/lib/libCommon-objc_$(CONFIGURATION)_$(PLATFORM_NAME).a
-lCommon-objc_$(CONFIGURATION)_$(PLATFORM_NAME)
-lPhoton-objc_$(CONFIGURATION)_$(PLATFORM_NAME)

Comments

  • Kaiserludi
    Options
    Looks, like you have left out the first line on copying them into the forums. This way the first of the 3 left lines will not fulfill its purpose.
    The full code would be:
    -force_load
    ../../Common-objc/lib/libCommon-objc_$(CONFIGURATION)_$(PLATFORM_NAME).a
    -lPhoton-objc_$(CONFIGURATION)_$(PLATFORM_NAME)
    -lCommon-objc_$(CONFIGURATION)_$(PLATFORM_NAME)
    
    The first two lines will be treated like one line by Xcode's underlying linker, but due two some lacking functionality of Xcode it displays them as two lines.
    This line tells the linker to load all symbols of the Common-objc.a library, not stripping symbols out, for which it could not see any code using them. Due to a bug in Xcode this is needed for all libraries, that are using the objC language feature of categories, as otherwise they are stripped out of the application binary, no matter if they are used, or not, making the application crash, when it calls a method, which is using them. An alternative would be to use all_load to do this for all libraries, you use, at once, but as some libraries in that case will complain about duplicate symbols and others could blew up your app-size quite a bit, its best to use force_load, so that only the libs, for which it is needed, are affected.

    The other two lines are just telling the linker, which libraries it should include into the application binary. The $() parts are replaced by XCode according to your currently chosen configuration and platform, before the linker gets the names, so the first one is automatically set to either debug or release, the second one to iphoneos or iphonesimulator, the l at the start tells the linker to look in the library search paths for a file beginning with "lib" and ending with ".a"
  • Thank you!
    By the way , this is only set in " Targets Info " ??
    When I set it in "Project info",it will build error . Is it a Xcode Bug ???
  • Kaiserludi
    Options
    My guess would be, that it is an issue with your particular project-setup, as I have just tested it here with demo_iphone_photon_obj and having those line only in project settings or having them in both, target-settings and project-settings, both worked fine. Maybe you have multiple targets in you projects? In that case project-settings are for all of them, which do not overwrite them. I would then check, for which of the targets you are getting the build-errors.