Hey guys...

Firstly, responding to Bill...  I've been told that the three leading  
underscores is perfectly normal for Darwin/OSX.  The code you  
provided compiled and executed with absolutely no comment or  
complaint;  my apologies for not having tried it before.  I've been  
skimming through various documents at <http://developer.apple.com/>,  
and although the track you're on is somewhere over my head - that is,  
I don't know enough about C or libraries to follow you entirely - my  
sense is that the problem is probably something different.

I've tried one new thing, with interesting results, the use of a "- 
flat_namespace" flag for the compiler (actually it gets passed to the  
linker, I suppose.)  The problems that occurred with that are noted  
further down.  First, though, I thought I might share a few snippets  
of things that stood out in the documents I read.  I figured that if  
a 'NOTE' statement was emphasized in it's own text box, it probably  
signified behavior that was unique to Darwin/OSX, and that there was  
a chance that one or more of them might make the whole situation  
suddenly obvious to someone.

----------------------
> "Important: Mac OS X does not support the concept of weak linking  
> as it is found in systems like Linux. If you override one symbol,  
> you must override all of the symbols in that object file."
(from <http://developer.apple.com/documentation/Porting/Conceptual/ 
PortingUnix/compiling/chapter_4_section_9.html>)
----------------------
> "Important: All runtime loaded should be opened into the local  
> scope. Adhering to this rule makes finding symbols at runtime as  
> fast as possible."

> "Note: Name conflicts between dynamic shared libraries are not  
> discovered at compile time, link time, or runtime. The dlsym  
> function uses string matching to find symbols. If two libraries use  
> the same name for a function, the first one that matches the symbol  
> name given to dlsym is returned."

> "Note: In Mac OS X you can interpose only dependent libraries.  
> Symbols in runtime loaded libraries cannot be interposed."
(from <http://developer.apple.com/documentation/DeveloperTools/ 
Conceptual/DynamicLibraries/Articles/ 
DynamicLibraryUsageGuidelines.html#//apple_ref/doc/uid/TP40001928-SW10>)
----------------------
> "The two-level namespace design has many advantages for Carbon  
> applications. However, it can cause problems for many traditional  
> UNIX applications if they were designed to work in a flat namespace  
> environment [...]  To allow the application to override references  
> made by libfoo to libbar, you would use the flag -flat_namespace.  
> The ld(1) man page has a more detailed discussion of this flag. The  
> two-level namespace is discussed at <http://developer.apple.com/ 
> releasenotes/DeveloperTools/TwoLevelNamespaces.html.>"
(from <http://developer.apple.com/documentation/Porting/Conceptual/ 
PortingUnix/compiling/chapter_4_section_7.html#//apple_ref/doc/uid/ 
TP40002850-BCIHJBBF>).
----------------------

There's a very good guide to how programs are actually executed on  
the Macintosh at <http://0xfe.blogspot.com/2006/03/how-os-x-executes- 
applications.html>, if anyone's interested.

Now, on to things that I've done myself.  I just finished trying to  
compile without the direct library reference, and with the "- 
flat_namespace" flag (which seems obvious in retrospect).  This gave  
'dyld' (the OS X dynamic linker) access to many more libraries than  
it had previously been aware of, including "/usr/lib/libgcc_s. 
1.dylib".  I'll append the list of all these libraries to the bottom  
of this message, in case it might be helpful.  The final "cc -o gtk- 
gnutella" command failed with multiple 'multiple definitions of  
symbol' errors:

> cc -o gtk-gnutella  main.o if/bridge/ui2c.o if/bridge/c2ui.o if/ 
> gnet_property.o if/gui_property.o -Lcore -lcore -Ldht -ldht -Lui/ 
> gtk -lgtk-common -lgtkx -lgtk-common -ldht -lcore -Llib -lshared -L/ 
> usr/local/lib -L/usr/X11R6/lib -lgtk -lgdk -lXext -lX11 -lm - 
> lglib   -L/usr/local/lib -lglib   -lxml2 -lz -liconv -lm    -L/opt/ 
> local/lib -ldbus-1   -L/usr/local/lib -lgnutls    -L/usr/local/lib - 
> lsqlite3   -mcpu=7450 -fast -mpim-altivec -maltivec -mabi=altivec - 
> ggdb3 -flat_namespace -L/usr/lib -L/usr/local/lib -L/usr/X11R6/lib - 
> framework Accelerate -lz -lintl -lresolv -liconv
>
>       [list of libraries logged by dyld due to the RC_TRACE_DYLIBS and  
> RC_TRACE_ARCHIVES enviroment variables moved further down...]
>
> /usr/bin/ld: multiple definitions of symbol _g_realloc
> lib/libshared.a(glib-missing.o) definition of _g_realloc in section  
> (__TEXT,__text)
> /usr/local/lib/libglib.dylib(gmem.lo) definition of _g_realloc
> /usr/bin/ld: multiple definitions of symbol _g_malloc
> lib/libshared.a(glib-missing.o) definition of _g_malloc in section  
> (__TEXT,__text)
> /usr/local/lib/libglib.dylib(gmem.lo) definition of _g_malloc
> /usr/bin/ld: multiple definitions of symbol _g_free
> lib/libshared.a(glib-missing.o) definition of _g_free in section  
> (__TEXT,__text)
> /usr/local/lib/libglib.dylib(gmem.lo) definition of _g_free
> /usr/bin/ld: multiple definitions of symbol _g_malloc0
> lib/libshared.a(glib-missing.o) definition of _g_malloc0 in section  
> (__TEXT,__text)
> /usr/local/lib/libglib.dylib(gmem.lo) definition of _g_malloc0
> collect2: ld returned 1 exit status
> make[2]: *** [gtk-gnutella] Error 1
> make[1]: *** [subdirs] Error 1
> make: *** [all] Error 2

There was also one interesting warning from ld:
> /usr/bin/ld: warning can't open dynamic library: /opt/local/lib/ 
> libiconv.2.dylib (checking for undefined symbols may be affected)  
> (No such file or directory, errno = 2)

I'll look for a loose symbolic link, because that's probably the  
cause I think.  "/usr/local/lib/libiconv.2.4.0.dylib" was found  
without problem.  As to why multiple copies are being referenced, I  
don't know.

Here's the list of all the libraries dyld reported using:

> [Logging for Build & Integration] Used static archive: /ml/prj/gtk- 
> gnutella/src/core/libcore.a
> [Logging for Build & Integration] Used static archive: /ml/prj/gtk- 
> gnutella/src/dht/libdht.a
> [Logging for Build & Integration] Used static archive: /ml/prj/gtk- 
> gnutella/src/ui/gtk/libgtk-common.a
> [Logging for Build & Integration] Used static archive: /ml/prj/gtk- 
> gnutella/src/ui/gtk/libgtkx.a
> [Logging for Build & Integration] Used static archive: /ml/prj/gtk- 
> gnutella/src/ui/gtk/libgtk-common.a
> [Logging for Build & Integration] Used static archive: /ml/prj/gtk- 
> gnutella/src/lib/libshared.a
>               [...ld warning occurred at this point.]
> [Logging for Build & Integration] Used dynamic library: /usr/local/ 
> lib/libgtk-1.2.0.9.1.dylib
> [Logging for Build & Integration] Used dynamic library: /usr/local/ 
> lib/libgdk-1.2.0.9.1.dylib
> [Logging for Build & Integration] Used dynamic library: /usr/X11R6/ 
> lib/libXext.6.4.dylib
> [Logging for Build & Integration] Used dynamic library: /usr/X11R6/ 
> lib/libX11.6.2.dylib
> [Logging for Build & Integration] Used dynamic library: /usr/lib/ 
> libSystem.B.dylib
> [Logging for Build & Integration] Used dynamic library: /usr/local/ 
> lib/libglib-1.2.0.0.10.dylib
> [Logging for Build & Integration] Used dynamic library: /opt/local/ 
> lib/libxml2.2.6.23.dylib
> [Logging for Build & Integration] Used dynamic library: /opt/local/ 
> lib/libz.1.2.3.dylib
> [Logging for Build & Integration] Used dynamic library: /usr/local/ 
> lib/libiconv.2.4.0.dylib
> [Logging for Build & Integration] Used dynamic library: /opt/local/ 
> lib/libdbus-1.2.0.0.dylib
> [Logging for Build & Integration] Used dynamic library: /usr/local/ 
> lib/libgnutls.13.0.6.dylib
> [Logging for Build & Integration] Used dynamic library: /usr/local/ 
> lib/libsqlite3.0.8.6.dylib
> [Logging for Build & Integration] Used dynamic library: /System/ 
> Library/Frameworks/Accelerate.framework/Versions/A/Accelerate
> [Logging for Build & Integration] Used dynamic library: /usr/local/ 
> lib/libintl.8.0.0.dylib
> [Logging for Build & Integration] Used dynamic library: /usr/lib/ 
> libresolv.9.dylib
> [Logging for Build & Integration] Used dynamic library: /usr/lib/ 
> libmx.A.dylib
> [Logging for Build & Integration] Used dynamic library: /usr/local/ 
> lib/libgmodule-1.2.0.0.10.dylib
> [Logging for Build & Integration] Used dynamic library: /usr/lib/ 
> libgcc_s.1.dylib
> [Logging for Build & Integration] Used dynamic library: /opt/local/ 
> lib/libgmodule-1.2.0.0.10.dylib
> [Logging for Build & Integration] Used dynamic library: /opt/local/ 
> lib/libglib-1.2.0.0.10.dylib
> [Logging for Build & Integration] Used dynamic library: /usr/lib/ 
> system/libmathCommon.A.dylib
> [Logging for Build & Integration] Used dynamic library: /usr/local/ 
> lib/libtasn1.3.0.4.dylib
> [Logging for Build & Integration] Used dynamic library: /usr/lib/ 
> libz.1.2.3.dylib
> [Logging for Build & Integration] Used dynamic library: /usr/local/ 
> lib/libgcrypt.11.2.1.dylib
> [Logging for Build & Integration] Used dynamic library: /usr/local/ 
> lib/libgpg-error.0.2.1.dylib
> [Logging for Build & Integration] Used dynamic library: /usr/lib/ 
> libiconv.2.dylib
> [Logging for Build & Integration] Used dynamic library: /System/ 
> Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
> [Logging for Build & Integration] Used dynamic library: /System/ 
> Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/ 
> vImage.framework/Versions/A/vImage
> [Logging for Build & Integration] Used dynamic library: /System/ 
> Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/ 
> vecLib.framework/Versions/A/vecLib
> [Logging for Build & Integration] Used dynamic library: /usr/lib/ 
> libicucore.A.dylib
> [Logging for Build & Integration] Used dynamic library: /usr/lib/ 
> libauto.dylib
> [Logging for Build & Integration] Used dynamic library: /usr/lib/ 
> libobjc.A.dylib
> [Logging for Build & Integration] Used dynamic library: /System/ 
> Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/ 
> vecLib.framework/Versions/A/libvMisc.dylib
> [Logging for Build & Integration] Used dynamic library: /System/ 
> Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/ 
> vecLib.framework/Versions/A/libvDSP.dylib
> [Logging for Build & Integration] Used dynamic library: /System/ 
> Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/ 
> vecLib.framework/Versions/A/libBLAS.dylib
> [Logging for Build & Integration] Used dynamic library: /System/ 
> Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/ 
> vecLib.framework/Versions/A/libLAPACK.dylib
> [Logging for Build & Integration] Used static archive: /usr/lib/gcc/ 
> darwin/3.3/libgcc.a

Hope this is helpful, or at least interesting.

regards,
matt.




-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Gtk-gnutella-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtk-gnutella-devel

Reply via email to