It's hard to troubleshoot the exact problem without code, but this most often happens when a variable is declared *and* defined directly in a .h file. The solution, usually, is to *declare* the variable as "extern type blah;" in the include file and *define* the variable in one .c file as "type blah = value;". The linker then ensures that all references to variable "blah" point to that one definition. unixprgrmr01@gmail.com wrote: > I am trying to link library xy.a composed of x.o containing function x() and > y.o containing function y() with d.o giving executable d > > I call both x() and y() from d.cpp. When I comment out the function call to > y() in d.cpp it links just fine with library xy.a giving executable d BUT > when I uncomment the function call to y() I get duplicate variable > declaration errors. > > Note that I need x.o and y.o in a library because I also link them with e.o > to give executable e . Both x() and y() are called from both d and e > executables. > > I use the same custom include files in x.o y.o d.o and e.o. I am getting > duplicate variable errors from the variables declared in these custom > include files. > > I also include standard include files such as and etc. > etc. in all 4 .o's but I don't get duplicate variable errors from these. > > I am #ifndef ing the entire include file just as is done with etc. > What am I doing wrong, that at link time I get duplicate variable errors? > > Thanks for your help! > > > > ------------------------------------------------------------------------ > > --------------------------------------------------- > PLUG-discuss mailing list - PLUG-discuss@lists.plug.phoenix.az.us > To subscribe, unsubscribe, or to change your mail settings: > http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss