schell@iris.ucdavis.edu (Stephan Schell) (09/19/89)
I recently finished debugging a large program that included both C and FORTRAN routines. In each language there was a routine that required a double precision square-root. When I compiled and linked, I got a "/bin/ld: duplicate symbol" error and eventually tracked it down to be the external data symbol "dsqrtconfig" present in both /lib/libm.a(sqrt.o) and /usr/lib/libcl.a(f_sqrt.o). Of course, both .o files had the same value for the symbol, but the linker refused to link it all into an executable program! Is there a proper fix for this other than doing a relocatable link on the FORTRAN object code to link in its square-root routine and then "localizing" the external symbol (i.e. "ld -r -o fjunk.o -h dsqrtconfig froutines.o") then supply fjunk.o to the "cc" command along with the C routines? This fix seems particularly stupid and dangerous to me, as well as standing in the way of developing stable mixed-language programs. Any ideas? Stephan Schell schell@iris.ucdavis.edu ...ucbvax!ucdavis!iris!schell Dept. of EE & CS Univ. of Calif., Davis
darrylo@hpnmdla.HP.COM (Darryl Okahata) (09/20/89)
In comp.sys.hp, schell@iris.ucdavis.edu (Stephan Schell) writes: > I recently finished debugging a large program that included both C and > FORTRAN routines. In each language there was a routine that required > a double precision square-root. When I compiled and linked, I got a I am told that the following will work as a temporary workaround: ------------------------------------------------------------------------------- cd /lib cp libm.a libm.a.old ar xv libm.a sqrt.o mv sqrt.o temp.o ld -r -h dsqrtconfig -o sqrt.o temp.o ar rv libm.a sqrt.o ------------------------------------------------------------------------------- Please note that I have NOT tested this. This problem is fixed in HP-UX 7.0 (the S800 HP-UX version number is jumping from 3.1 to 7.0). -- Darryl Okahata darrylo%hpnmd@hpcea.HP.COM Disclaimer: the above is the author's personal opinion and is not the opinion or policy of Hewlett-Packard or of the little green men that have been following him all day.
bla@hpcupt1.HP.COM (Brad Ahlf) (09/21/89)
> When I compiled and linked, I got a "/bin/ld: duplicate > symbol" error and eventually tracked it down to be the external data symbol > "dsqrtconfig" present in both /lib/libm.a(sqrt.o) and > /usr/lib/libcl.a(f_sqrt.o). > Is there a proper fix for this other than ... This is a KNOWN PROBLEM on 3.1, FIXED for 7.0. A PATCH can be obtained through the normal Response Center support process. Service Request number is 5000-440735. The patch file sqrt.o is available on the HP patch machine in the 800-3.10/Libm directory. A quick WORKAROUND is to 'hide' the symbol in either of the two libraries. This will make the 'global' symbol into a 'static' symbol in the .o file and the linker will not complain and the routine should still work ok. Then you no longer need to alter your compile/link scripts. For example: #cd /lib #cp libm.a libm.a.old #ar xv libm.a sqrt.o #mv sqrt.o temp.o #ld -r -h dsqrtconfig -o sqrt.o temp.o #ar rv libm.a sqrt.o