• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: "Flattening" a static library
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "Flattening" a static library


  • Subject: Re: "Flattening" a static library
  • From: Rush Manbert <email@hidden>
  • Date: Thu, 03 Nov 2005 08:41:49 -0800

Daniel Jalkut wrote:
Hi Rush - I thank you for responding. I think you sort of understand my problem but not entirely. This issue is not so much about header files, but about the linker phase. When I compile all my constituent files into a static library, it's easy to limit the header file access to that interface, but the linker will still recognize the static library as a collection of individual .o files, and therefore resolve all symbols from those files as if they were defined in individual .c files in the project.

Oh, sorry. So some of the functions in the static lib don't get pulled in by the linker because it already has a function with the same signature that is part of your app?

It sounds like you have these limitations:

* You're in C, so no namespaces.

* You can't change the static lib sources, or their file names.

* You can't change the conflicting names in the app.
(If this is not true, then how about adding module-specific function name prefixes to the app sources? That will keep them from conflicting with your lib sources, although it's sort of backward from the more general solution of adding module-specific prefixes to the static lib sources. That would keep the static lib from conflicting with anything in the next app you link to it.)


The linker can link several object files into a single object file. Can you do this with your static lib object files, then create a static library from the single object file that you created? It seems like that would pull in all of your code, and it will be correctly linked internally. Of course, then you will have problems with multiple symbol definitions. (which you might be able to sidestep by using the dangerous -m flag to ld)

Another approach along these lines. Link all your static lib object files together to form a single object file, then apply a binary edit (that you must write, I guess) that removes all entry point definitions except your single function. Then throw the resulting file into the final link, or make a static lib out of it. This is like your idea of editing the static lib, but it might be easier to strip the entry point definitions than it would be to change all of them.

Hmmm, maybe making your "super-C" file isn't such a bad idea. There aren't any pretty solutions that I can think of...
- Rush
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
  • Follow-Ups:
    • Re: "Flattening" a static library
      • From: Daniel Jalkut <email@hidden>
References: 
 >"Flattening" a static library (From: Daniel Jalkut <email@hidden>)
 >Re: "Flattening" a static library (From: Rush Manbert <email@hidden>)
 >Re: "Flattening" a static library (From: Daniel Jalkut <email@hidden>)

  • Prev by Date: Re: Any tool to compare resource forks?
  • Next by Date: Interface Builder, springy objects and TextField behaviour
  • Previous by thread: Re: "Flattening" a static library
  • Next by thread: Re: "Flattening" a static library
  • Index(es):
    • Date
    • Thread