• 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
Getting the correct libraries
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting the correct libraries


  • Subject: Getting the correct libraries
  • From: Rush Manbert <email@hidden>
  • Date: Tue, 08 Mar 2005 12:09:16 -0800

I have been putting together a capability to use the xml msecurity library that is available at http://www.aleksey.com/xmlsec/.

In order to do this, I had to get libxml2, libxslt, and openssl. I did all this, and used the standard distributions to make static libraries for all of them.

Once all of the static libraries were built, I made an Xcode project that would build the test program for the xml security library. In my project, I included exactly the versions of the libraries that I needed. My goal was to create the application such that it was statically linked to all of the xml related code, and would dynamically link to the Core Services framework.

When I ran the build in Xcode, it was successful. However, examination of the resulting executable showed that it was much too small to have been statically linked. The loader command line that Xcode used is this:

/usr/bin/gcc-3.3 -o /Users/rmanbert/Sources/LibXsec/XmlSecTool/build/XmlSecTool -L/Users/rmanbert/Sources/LibXsec/XmlSecTool/build -L/Users/rmanbert/Sources/LibXsec/xmlsec1-1.2.7/Installation/lib -L/Users/rmanbert/Sources/LibXml2/libxslt-1.1.12/Installation/lib -L/Users/rmanbert/Sources/LibXml2/libxml2-2.6.17/Installation/lib -L/Users/rmanbert/Sources/OpenSsl/openssl-0.9.7d -L/Users/rmanbert/lib -F/Users/rmanbert/Sources/LibXsec/XmlSecTool/build -filelist /Users/rmanbert/Sources/LibXsec/XmlSecTool/build/XmlSecTool.build/XmlSecTool.build/Objects-normal/XmlSecTool.LinkFileList -lxmlsec1-openssl -lxmlsec1 -lxslt -lxml2 -lcrypto -framework CoreServices -arch ppc -Wl,-no_arch_warnings

The problem is in the library search path order. Even though my (correct) paths are specified for the static versions of the libraries, the fact that they are searched for as the result of -l<libraryname> means that there are other paths that are searched before these. As it turns out, libxml2.2.dylib is installed in /usr/lib, with the link libxml2.dylib pointing to it. It appears that the linker finds that version and links to it.

This is bad, because I need to exactly control what versions of the xml code are used by my application. I can't rely on whatever the machine happens to have on it. (I'm building a product that incorporates this stuff.)

I finally got around this problem by linking the application by hand on the command line. My linker command was this:

/usr/bin/gcc-3.3 -o /Users/rmanbert/Sources/LibXsec/XmlSecTool/build/XmlSecTool -filelist /Users/rmanbert/Sources/LibXsec/XmlSecTool/build/XmlSecTool.build/XmlSecTool.build/Objects-normal/XmlSecTool.LinkFileList /Users/rmanbert/lib/libxmlsec1-openssl.a /Users/rmanbert/lib/libxmlsec1.a /Users/rmanbert/lib/libxslt.a /Users/rmanbert/lib/libcrypto.a /Users/rmanbert/lib/libxml2.a -framework CoreServices -arch ppc

Essentially, I specified exactly which static libraries I needed.

I read through the man page for gcc (which is how I learned that exactly specifying the libraries would link against them, just like -l would.) and I don't see any way to disable the predefined library search path order. I also don't see any way to tell it to search my paths first. (Interestingly, the Apple-specific -F option prepends the specified path to the search order...) It may be that gcc limits what can be done via command line options. If this is true, then I would be looking for a way to have Xcode generate a linker command line that looks like the one I used, so that the static libraries that I included in the project are guaranteed to be the ones that are linked against.

Does anyone have any suggestions here?

Thanks,
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


  • Prev by Date: Re: Weak linking in Xcode
  • Next by Date: XCode documentation index; executable runtime paths
  • Previous by thread: Re: Weak linking in Xcode
  • Next by thread: XCode documentation index; executable runtime paths
  • Index(es):
    • Date
    • Thread