Search code examples
cmacoslibtool

ld: duplicate symbol _dbg_char


Getting a linker error on osx (no errors on linux or fbsd for the same code):

ld: duplicate symbol _dbg_char in .libs/liboekernel_la-OEK_get.o and .libs/liboekernel_la-OEK.o

the 2 libs listed in the error are mine but the symbol isn't. c++flint confirms '_dbg_char' is in both libs but I'm not sure how to find where it comes from.

tricks, strategies, outright answers for how to id _dbg_char would be greatly appreciated.

project is using libtool/autotools and gcc 4.01


Solution

  • Found a logging / debug macro that was defining dbg_char by 'dbg_ ## t'. fix was to make it static. lessons learned:

    1. osx adds a leading _ to symbol names. it wasn't until i ran nm on linux and saw the same symbol without the leading _ that i thought to search the codebase for "dbg_" instead of "_dbg_"
    2. osx was right to complain
    3. rich irony that cut-and-pasting a debug macro i didn't fully understand caused me so much trouble