Operating System - HP-UX
1834827 Members
2850 Online
110070 Solutions
New Discussion

ld: Duplicate symbol "x" in files

 
Rick Burge_3
Occasional Advisor

ld: Duplicate symbol "x" in files

I have code that compiles and links without incident on an 11.23 system with the aCC 5.55 compiler/linker.

That same code on an 11.11 (aCC 3.55) generates the following:
ld: Duplicate symbol "x" in files filex and filey
ld: Duplicate symbol "y" in files filex and filey
It usually prints both lines for each item in the link line.
This only seems to happen when I am making a shared library: aCC -b -o rick.sl filex.o filey.o
Now the compiler doc says something about it but it has to do with templates. I am not using templates. If I take the doc into consideration regarding auto instantiation and the like I end up running into problems with shared libraries linking but not the executable and it becomes a problem with fixing it one palce only to have it popout in another place.
There is something else at work here, any suggestions?

Thanks,
Rick
2 REPLIES 2
K R Prayag_1
Occasional Advisor

Re: ld: Duplicate symbol "x" in files

Rick,
It looks like that the aCC 3.55 is taking an exception to same variables/objects being declared in two object files that you are trying to link together. You may want to check that the variables are not the same. If you need the names to be same then you could put them in a header file and declare them as extern.

Hope this helps.

Regards,
Kamesh Prayag
Laurent Menase
Honored Contributor

Re: ld: Duplicate symbol "x" in files

If your 2 x must be different, then you must declare them as static,
If they must be shared you must set them as extern.
If they are different, but you can't change them to static then you can hide them doing a
ld -r filex.o -h x -h y -o filex2.o