1820390 Members
3569 Online
109623 Solutions
New Discussion юеВ

Duplicate Symbols

 
David Mann
Occasional Contributor

Duplicate Symbols

I am in the process of porting an aplication to HPUX11 which has be sucessfully ported to many other platforms, and I keep getting duplicate symbols on the link line for objects compiled with aCC.

Is there a link flag that could persuade the linker to ignore this, as it is not a problem on any other platform.

Many thanks,

Dave

/usr/ccs/bin/ld: Duplicate symbol "lp_code" in files main.o and exit.o
/usr/ccs/bin/ld: Duplicate symbol "__SIGEV_NONE" in files /usr/users1/dmann/TD1_Ver1.2s/lib/hp11/src/vers.o and /usr/local/flexlm/v6.1/hp700_u9/lm_new.o
/usr/ccs/bin/ld: Duplicate symbol "__SIGEV_SIGNAL" in files /usr/users1/dmann/TD1_Ver1.2s/lib/hp11/src/vers.o and /usr/local/flexlm/v6.1/hp700_u9/lm_new.o
/usr/ccs/bin/ld: Duplicate symbol "__SIGEV_THREAD" in files /usr/users1/dmann/TD1_Ver1.2s/lib/hp11/src/vers.o and /usr/local/flexlm/v6.1/hp700_u9/lm_new.o
/usr/ccs/bin/ld: Duplicate symbol "CLOCK_INVALID" in files /usr/users1/dmann/TD1_Ver1.2s/lib/hp11/src/vers.o and /usr/local/flexlm/v6.1/hp700_u9/lm_new.o
/usr/ccs/bin/ld: Duplicate symbol "CLOCK_REALTIME" in files /usr/users1/dmann/TD1_Ver1.2s/lib/hp11/src/vers.o and /usr/local/flexlm/v6.1/hp700_u9/lm_new.o
/usr/ccs/bin/ld: Duplicate symbol "CLOCK_VIRTUAL" in files /usr/users1/dmann/TD1_Ver1.2s/lib/hp11/src/vers.o and /usr/local/flexlm/v6.1/hp700_u9/lm_new.o
/usr/ccs/bin/ld: Duplicate symbol "CLOCK_PROFILE" in files /usr/users1/dmann/TD1_Ver1.2s/lib/hp11/src/vers.o and /usr/local/flexlm/v6.1/hp700_u9/lm_new.o
/usr/ccs/bin/ld: Duplicate symbol "RTTIMER0" in files /usr/users1/dmann/TD1_Ver1.2s/lib/hp11/src/vers.o and /usr/local/flexlm/v6.1/hp700_u9/lm_new.o
/usr/ccs/bin/ld: Duplicate symbol "RTTIMER1" in files /usr/users1/dmann/TD1_Ver1.2s/lib/hp11/src/vers.o and /usr/local/flexlm/v6.1/hp700_u9/lm_new.o
/usr/ccs/bin/ld: Found 10 duplicate symbol(s)
*** Error exit code 1
6 REPLIES 6
Steve Steel
Honored Contributor

Re: Duplicate Symbols

Hi

try via

http://atwnt961.external.hp.com/dspp/home/home_HomePage_IDX/1,1292,,00.html


Technical Resources


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Steven Gillard_2
Honored Contributor

Re: Duplicate Symbols

A couple of suggestions:

- Make sure you have the latest aCC version/patch, and that your linker is patched up to date. The latest ld patch is PHSS_24303, and you can find aCC information at:

http://atwnt938.external.hp.com/dspp/tech/tech_TechSoftwareDetailPage_IDX/1,1703,1743,00.html

- If you really do have the same symbols defined (as opposed to declared) in multiple .o files, then ideally you should fix your code to ensure that you are not defining symbols multiple times (eg defined in .h files that are included by multiple .c files).

- If this isn't possible, you may be able to list the symbol names with the -h option to the linker. From the ld man page:

-h symbol Prior to writing the symbol table to the output file, mark this name as ``local'' so that it is no longer externally visible. This ensures that this particular entry will not clash with a definition in another file during future processing by ld.

More than one symbol can be specified, but -h must precede each one. If used when building a shared library or program, this option prevents the named symbol from being visible to the dynamic loader.


Regards,
Steve
T G Manikandan
Honored Contributor

Re: Duplicate Symbols

Dave,

I seem to remember that there is a switch for hiding "undefined symbols" error messages, but I don't think it will work for duplicate symbols. (However I was unable to find it it the aCC docu right now.)

Unfortunately you don't show the linker command line. I suggest to use nm to find out which of the libs that you link to define the symbols that are duplicate. This way, you can try and eliminate the duplicity.

Good luck,

Martin

David Mann
Occasional Contributor

Re: Duplicate Symbols

 
Steven Gillard_2
Honored Contributor

Re: Duplicate Symbols

David,

The fact that this comes from a system include file (time.h) concerns me a little. It should be quite safe to have different objects include the same .h files from /usr/include without duplicate symbols being generated. If it was your own .h file generating the error then thats a different matter.

Try installing the header file patch, PHCO_23963, as it contains some fixes for time.h which may make a difference. And if you're still having problems after that, I would log a call with HP providing a simple example.

As a workaround, you can pass arguments to the linker through aCC by using the -Wl, option.

For example:

$ aCC ... -Wl,-h,CLOCK_INVALID,-h,CLOCK_REALTIME,-h,...

Regards,
Steve