shared library multilple definitions

view story

http://www.linuxforums.org – Hi, I have tried for weeks. I am creating a shared library from two object files a.o and b.o. Both a and b are classes that depend on a third-party library and class b wraps class a. and therefore, both a.o and b.o have the same globals defined from the third-party api. So I create a.o with g++ -c -fPIC -Wall ${CFLAGS} ${INCLUDES} ${LDFLAGS} a.cpp and b.o with: g++ -c -fPIC -Wall ${INCLUDES} b.cpp gcc -shared -Wl,-soname,libab.so.1 -o libab.so.1.0.1 a.o b.o When I combine them into the shared library I get a lot of: a.o:(.bss+0xc): first defined here b.o:(.bss+0x10): multiple definition of `ERROR' ...etc. All of the multiple definitions are define in the third-party headers. I tried to see if I could 'undefine' all of these defines in b.o, but I may have gotten the syntax wrong because when I run 'nm' on b.o - all of these sames defines are there. I"m sure people have had this problem before, is there a conventional way to get around this? thanks, (HowTos)