Linking Troubles
Linking Troubles
- Subject: Linking Troubles
- From: Scott Thompson <email@hidden>
- Date: Thu, 22 Jul 2004 11:18:48 -0500
I've been struggling with a build problem for quite some time now and=20
I've come to the conclusion that there is just something about the=20
Mach-O linking process that I don't understand. I will describe what I=20=
think I want to do below and hopefully you kind folks can tell me what=20=
it is I really would like to do. More importantly, however, I hope=20
you'll be able to explain the linking process to me, or at the very=20
least point me to documentation with more helpful information than the=20=
XCode online-help has proven to contain.
I'm working on an application that is currently built in separate=20
targets. The lowest level is a library of code for accessing a=20
database. I currently have that target building as a Framework so that=20=
it's code and headers can be exported to other targets. This is the=20
Database Framework.
The next target is a library of platform-independent code that uses the=20=
Database Framework to unarchive model objects and vend them to other=20
applications. Again, I set this up as a framework so that it's=20
interfaces would be available to other Targets. As it makes use of the=20=
database, this framework links to Database Framework. Let's call this=20
the Model Framework.
Finally I have an application target. The application target uses the=20=
services of the Model Framework to provide interesting behaviors. As=20
it needs to use services that the Model Framework provides... it links=20=
to the model framework. This is the Application target.
Application -depends on-> Model -depends on-> Database
I've set up my XCode project so that it has these three targets. I've=20=
made the targets depend on one another in the proper way so that=20
building the Application causes the two framework targets to be built=20
in the proper order. I've also included the Database Framework from=20
the "Products" group to the "Frameworks & Libraries" section of the=20
Model Framework. Then I included the Model Framework from the=20
"Products" group into the "Frameworks & Libraries" of the Application.
What I expect from this process is that when I build the application,=20
it will see if the Model Framework needs to be built. The Model=20
framework will, in turn, see if the Database Framework needs to be=20
built. I have been very successful in getting the targets to build in=20=
the correct order and at the correct times. The problem I am having=20
comes at link time.
When trying to link the project, the Database Framework and Model=20
Framework appear to link just fine. When it comes time to link the=20
application, however, the linker warns that:
ld: warning can't open dynamic library: blah blah blah...
Followed by errors galore about unresolved symbols.
I looked that up on the net and learned a bit about this thing called=20
the "@executable_path". Since my frameworks are pretty much private=20
frameworks I decided to move them into the application bundle. I added=20=
a "Copy Files" phase which actually copies the products of the Database=20=
and Model frameworks into my executable at=20
MyApp.app/Contents/Frameworks. Then, for each of my frameworks, I=20
changed the "install path" option to read=20
"@executable_path/../Frameworks"
No dice, I still get the linker warning and the linker errors. I=20
verified that the files are actually copied into the application bundle=20=
as I expected them to be and they are both in the correct location. =20
Nevertheless I still see:
ld: warning can't open dynamic library:=20
@executable_path/../Frameworks/Database.framework/Versions/A/Database=20
(checking for undefined symbols may be affected) (No such file or=20
directory, errno =3D 2)
I suspect that the problem may have something to do with my dependency=20=
tree. Most specifically having one framework which depends on another=20=
framework. It seems that what may be happening is that the Model=20
framework expects to find the Database relative to one executable path=20=
while the application expects to find it at another. But I don't know=20=
that that is the case. I also don't know how ld resolves the=20
"@executable_path" metapath.
I realize that my setup is complex. I may=A0end up simplifying things =
so=20
that the Database and Model frameworks are actually just one big lump=20
of code. However I'd like to get the scheme I've outlined to work...=20
or at least I would like to understand why it doesn't work.
if you have specific knowlege that may be helpful in getting rid of=20
this annoying link error, I would appreciate any help.
Thanks!
Scott
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.