Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
newbie xcode linker question
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
mlabs  
View profile  
 More options Feb 6 2008, 12:37 am
Newsgroups: comp.sys.mac.programmer.help
From: mlabs <aaron.miramar.l...@gmail.com>
Date: Tue, 5 Feb 2008 21:37:24 -0800 (PST)
Local: Wed, Feb 6 2008 12:37 am
Subject: newbie xcode linker question
I'm trying to create a new framework. The source files need use
libxml2, which comes with the 10.5 sdk.
I added this to the header search paths:
/Developer/SDKs/MacOSX10.5.sdk/usr/include/libxml2
and got it to compile.

Next I drag-dropped libxml2.dylib into my xcode project under
'External Frameworks and Libraries' .. and also under 'Link Binary
With Libraries' just for good measure... no idea why I should specify
the link dependencies in two places but whatever...

I still get linker errors. So I looked at the build transcript and in
particular noticed that libxml2.dylib wasn't mentioned on the Ld
command-line ... even though it is referenced explicitly in the xcode
project...

Q: Shouldn't drag-dropping that dylib into the project GUI like that
be telling the linker 'hey i want to link with this dylib' ?
If not, what's the best way to link with external dylibs?

TIA


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mlabs  
View profile  
 More options Feb 6 2008, 2:34 am
Newsgroups: comp.sys.mac.programmer.help
From: mlabs <aaron.miramar.l...@gmail.com>
Date: Tue, 5 Feb 2008 23:34:30 -0800 (PST)
Local: Wed, Feb 6 2008 2:34 am
Subject: Re: newbie xcode linker question
I found that if in addition to having the refs to libxml2.2dylib in
the GUI, if I also used '-l xml2.2' in the 'Other LInker Flags'
section AND the path to the SDKs 'usr/lib' directory, it would link.
I don't know what is going on... can anybody explain?

for example, why '-l xml2.2' and not '-l libxml2.2' ?
why doesn't xcode pass the path to the file i drag-dropped to the
linker..?  'get info' seems to know where the thing is....
are these just bugs?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Patrick Machielse  
View profile  
 More options Feb 6 2008, 5:20 am
Newsgroups: comp.sys.mac.programmer.help
From: nore...@mail.invalid (Patrick Machielse)
Date: Wed, 6 Feb 2008 11:20:42 +0100
Local: Wed, Feb 6 2008 5:20 am
Subject: Re: newbie xcode linker question

mlabs <aaron.miramar.l...@gmail.com> wrote:
> I'm trying to create a new framework. The source files need use
> libxml2, which comes with the 10.5 sdk.
> I added this to the header search paths:
> /Developer/SDKs/MacOSX10.5.sdk/usr/include/libxml2
> and got it to compile.

> Next I drag-dropped libxml2.dylib into my xcode project under
> 'External Frameworks and Libraries' .. and also under 'Link Binary
> With Libraries' just for good measure... no idea why I should specify
> the link dependencies in two places but whatever...

> Q: Shouldn't drag-dropping that dylib into the project GUI like that
> be telling the linker 'hey i want to link with this dylib' ?
> If not, what's the best way to link with external dylibs?

Hi,

You must deal with two issues here: how the compiler and the linker find
headers and libraries, and how Xcode uses SDKs. These two settings
interact, so be careful when changing settings.

libxml is shipped in both 10.4 and 10.5. In your code, you should
include the headers like so:

#include <libxml/someheader.h>

The angle brackets denote a library, and ensure that the a number of
standard locations is searched for someheader.h (this probably includes
usr/include/libxml2, so you wouldn't need to add any custom search path
to the build settings).

To instruct ld to link against a library called 'libName' you specify
the linker flag '-lName'. That's the rule. To link against libxml2.dylyb
you would pass '-lxml2'. If you look in /usr/lib (on 10.5) you'll see
that this is acutally a symlink to the currently shipped version
libxml2.2.dylib. I believe that setting a linker flag in the build
settings and adding a library to the target's 'Link Binary With
Libraries' section amount to the same thing.

Note that all locations above are spcified from the root, and you should
not point to a path inside an SDK yourself. Instead, Xcode will
automatically prepend the search paths with the SDKROOT build setting.
This way, you can target a different OS version by changing just one (or
a handful) of settings.

I hope this gives you a (very short!) handle on linking and libraries,
but you probably want to read up on the documentation, or this will keep
coming back to hount you. I promise ;-)

patrick


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mlabs  
View profile  
 More options Feb 6 2008, 6:18 am
Newsgroups: comp.sys.mac.programmer.help
From: mlabs <aaron.miramar.l...@gmail.com>
Date: Wed, 6 Feb 2008 03:18:19 -0800 (PST)
Local: Wed, Feb 6 2008 6:18 am
Subject: Re: newbie xcode linker question
thanks -
since posting, i have found the documenataion on ld that says -lfoo
will look for libfoo.a .. how dumb is that .. lol
as for the xcode GUI - I think it is just buggy. There really should
not be a need to specify -lfoo in 'Othe LInker Options' *after*
dragging a ref to the dylib into the 'link binary with libraries'
section of the target .. that's pointless.. it has to be a bug ...
it's two ways of doing the same thing ...xcode should be able to
generate the correct ld -l from what i drag-dropped into that
section...

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Patrick Machielse  
View profile  
 More options Feb 6 2008, 7:10 am
Newsgroups: comp.sys.mac.programmer.help
From: nore...@mail.invalid (Patrick Machielse)
Date: Wed, 6 Feb 2008 13:10:22 +0100
Local: Wed, Feb 6 2008 7:10 am
Subject: Re: newbie xcode linker question

mlabs <aaron.miramar.l...@gmail.com> wrote:
> as for the xcode GUI - I think it is just buggy. There really should
> not be a need to specify -lfoo in 'Othe LInker Options' *after*
> dragging a ref to the dylib into the 'link binary with libraries'
> section of the target .. that's pointless.. it has to be a bug ...
> it's two ways of doing the same thing ...xcode should be able to
> generate the correct ld -l from what i drag-dropped into that
> section...

Make sure you add /usr/lib/libxml2.dylib, and not the dylib from one of
the SDKs. That should work. In general, if you add Mac OS X frameworks
to your project, choose the ones in /System/Library/Frameworks. At build
time the correct SDK version will be used.

patrick


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google