ld: duplicate symbol _g_bit_nth_lsf Mac OSX Leopard/Darwin

I have had some problems installing software from source on my Max OS X Leopard machine. I should thank Martin Szomszor for his help on getting this working, but after some time faffing we finally got it sorted out.

I found that I was having problems making software on Leopard, which I could build fine on my linux (fedora) machines. The error I was getting was:

ld: duplicate symbol _g_bit_nth_lsf in foo.o and bar.o

I am running Leopard 10.5.3. I was using glib2, installed via Fink, version number: 2.12.0-103. After spending lots of time googling I found the following article to be of the most use, “Wireshark with Macports”, where Anders Brownworth pointed out that the error was due to a “extern inline bug in glib/gutils.h which is easily fixed“.

So to fix this:

  • I located gutils.h, which I found here: /sw/include/glib-2.0/glib/gutils.h</li>

    • I then replaced these lines: `#ifdef G_IMPLEMENT_INLINES</p>

# define G_INLINE_FUNC

# undef G_CAN_INLINE

#elif defined (__GNUC__)

# define G_INLINE_FUNC extern inline

#elif defined (G_CAN_INLINE)`</li> * With this: `#ifdef G_IMPLEMENT_INLINES

# define G_INLINE_FUNC

# undef G_CAN_INLINE

#elif defined (__APPLE__)</p>

# define G_INLINE_FUNC static inline`</font> #elif defined (\_\_GNUC\_\_) \# define G\_INLINE\_FUNC extern inline #elif defined (G\_CAN\_INLINE)</code></li> * By adding these two middle lines: #elif defined (__APPLE__)</p> <p># define G_INLINE_FUNC static inline</li> * The start of the fragment of code was at line number _96_ in my **gutils.h** file</ul> Here is a link to my edited and working [gutils.h file](https://mmt.me.uk/blog/files/gutils.h). **Note 1:** I would make sure I get a copy of my original gutils.h file, as this may come in handy **Note 2:** There is a [patch](http://trac.macosforge.org/projects/macports/attachment/ticket/13006/glib2-inline.2.patch?format=raw) which one could apply to make the same changes which I have just described here. This patch follows this [ticket](http://trac.macports.org/ticket/13006). I didn’t know what to do with the patch file, so I ended up editing the file by hand:). I am guessing that is something todo with macports, mmm, nevermind, its working now.