Question

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

Was it helpful?

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

OTHER TIPS

You might want to check if both libs #include a header file that declare _dbg_char but miss the extern keyword. Maybe that's #ifdef 'ed out for other platforms so you only hit that problem on OS X.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top