Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Rép. : Re: Shared Objects and dyLibs



You probably have some code like this:

/* foo.h */

int foo;

/* foo.c */
#include "foo.h"

/* bar.c */
#include "foo.h"

Now, both foo.o and bar.o have common definitions of foo. This is bad for
many reasons that I won't go into now. Suffice it to say that you don't
want to do this. You should move the definition of foo from the header
into one of the .c files and make the header say:

/* foo.h */
extern int foo;

I'm guessing, but that's the most common way I've seen this particular
problem manifest itself.

matt.

On Tue, 30 Jan 2001, Florent wrote:

> Christoph Pfisterer wrote :
>
> > Florent wrote:
> >
> > >I am currently working on an OpenAL port to Darwin/MacOS X and I am
> > >having some troubles when building a dynamic library.
> > >I used the -dynamiclib option with cc to build the dynamic library,
> > >and I got the following error :
> > >
> > >ld: common symbols not allowed with MH_DYLIB output format
> >
> > You must compile the source files with the '-fno-common' compiler
> > flag. I'm not sure what they mean with common symbols, but using the
> > flag helps. ;-)
> >
> > Probably you'll also need to specify the '-undefined suppress' flag
> > when linking...
>
> Thanks. But the -fno-common didn't work, neither did the -undefined suppress flag...
> I still have :
>
> ld: common symbols not allowed with MH_DYLIB output format
> foo.o definition of common _foo (size X)
> ...
>
> where _foo is the symbol of a global variable. So it seems global variable symbols are not supported at all in MH_DYLIBs, or I am missing a flag...
> But in my case, I have no really need to share the symbol outside of the lib. I just want it to be statically linked with the library code. How can I tell to dyld which symbols should be exported and which should not ?
>
>
> ------------------------------------
> Now it's time to hang up your Internet connection and to come back to normal life...
> email@hidden (Florent Boudet)
> _______________________________________________
> darwin-development mailing list
> email@hidden
> http://www.lists.apple.com/mailman/listinfo/darwin-development


References: 
 >Rép. : Re: Shared Objects and dyLibs (From: Florent <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.