ld: multiply defined symbol

ld: multiply defined symbol

Post by Bard Laukv » Thu, 11 Aug 1994 20:04:02



What do I do when 2 third party libraries contain symbols with the same
name ? (i.e. dummy in liba and libb)
( Solaris 2.3 )

--
---------------------------------------------------------------------
B?rd Laukvik                           Tlf: +47-69 19 53 01
Ericsson Radar AS                       Fax: +47-69 19 57 12
Isebakke vn 49

NORWAY                                        

 
 
 

ld: multiply defined symbol

Post by Ade Bark » Fri, 12 Aug 1994 07:38:32


: What do I do when 2 third party libraries contain symbols with the same
: name ? (i.e. dummy in liba and libb)
: ( Solaris 2.3 )

You cry. Then you fiddle around with your source code /object
placement in the linking process to make yourself happy. Then
all fails and you cry again. =)

I guess in general:

a) If you need to use both symbols from both libraries, then
   you're probably be out of luck because the link-editing
   process will use the _first_ definition of the symbol.
   It may or may not generate an error message, depending
   whether you are linking dynamically or statically, and
   if one of the symbol (under static linking) is a `weak'
   symbol.

b) If you only need to use the symbol from one of the libraries,
   then put that library first, and link dynamically. The
   link editor will notice the second symbol with the same name
   but will (generally) not complain if the symbol represents
   a function, or a same-sized object.

   System V programmers using the -lucb library know the trick
   of putting the System V -lc library before the -lucb library
   so most functions will still link with the System V counterparts.

 
 
 

ld: multiply defined symbol

Post by Paul Flinde » Sat, 13 Aug 1994 18:43:48




>: What do I do when 2 third party libraries contain symbols with the same
>: name ? (i.e. dummy in liba and libb)
>: ( Solaris 2.3 )

>You cry. Then you fiddle around with your source code /object
>placement in the linking process to make yourself happy. Then
>all fails and you cry again. =)

If you need both calls and have a decent shared library scheme (ie one which
supports dlopen(), dlsym() (and related routines) then you can do it by
refering to the functions only by pointers and then initialising them with
calls to dlsym. This way the linker never sees the reference and should be
happy.

eg

void (*lib1_func)();
void (*lib2_func)();

void import_funcs()
{
    void *handle;

    handle = dlopen("/somewhere/lib/lib1.so", SOME_MODE_VALUE);
    *lib1_func = (void (*)()) dlsym(handle, "func");

    handle = dlopen("/somewhere_else/lib/lib2.so", SOME_MODE_VALUE);
    *lib2_func = (void (*)()) dlsym(handle, "func");

Quote:}

The SOME_MODE_VALUE values are a bit system specific but the above is only
intended to give you the idea anyway.

BTW - yes - it is horrible.
--

Delcam International PLC.       Tel:  +44 21 766 5544   Fax: +44 21 766 5511

 
 
 

1. ld: fatal error : symbols multiply-defined

Hello,

I am using ld's -r option to build combine several object files into a
single relocatable object file. This works fine but when I then
include this new relocatable object file into another ld command to
create an executable I get the following errors:

ra: /export/home/greg/code/prog >cc -dn -o invoker invoker.c testies.o
ld: fatal: symbol `_start' is multiply-defined:
(file /opt/SUNWspro/WS6U2/lib/crt1.o and file testies.o);
ld: fatal: symbol `_environ' is multiply-defined:
(file /opt/SUNWspro/WS6U2/lib/crt1.o and file testies.o);
ld: fatal: symbol `_init' is multiply-defined:
(file /opt/SUNWspro/WS6U2/lib/crti.o and file testies.o);
ld: fatal: symbol `___Argv' is multiply-defined:
(file /opt/SUNWspro/WS6U2/lib/crt1.o and file testies.o);
ld: fatal: symbol `__cg92_used' is multiply-defined:
(file /opt/SUNWspro/WS6U2/lib/crt1.o and file testies.o);
ld: fatal: symbol `_lib_version' is multiply-defined:
(file /opt/SUNWspro/WS6U2/lib/values-xa.o and file testies.o);
ld: fatal: symbol `__environ_lock' is multiply-defined:
(file /opt/SUNWspro/WS6U2/lib/crt1.o and file testies.o);
ld: fatal: symbol `_fini' is multiply-defined:
(file /opt/SUNWspro/WS6U2/lib/crti.o and file testies.o);
ld: fatal: File processing errors. No output written to invoker

I am running Solaris8.

Any ideas on how to fix this?

It appears the objects crt1.o, crti.o and values-xa.o are being
linked-in twice...each time ld is invoked. Is there any way to stop
this?

Thanks,
Greg

2. The superiority of alpha

3. ld: fatal: symbol `_init' is multiply defined???

4. Tunnelling IPX over IP

5. Problem: ld (linker) giving multiply defined symbol fatal errors

6. Help with sz

7. ld multiply defined error

8. listserv software for Linux

9. : ld error: _tolower & _toupper multiply defined

10. How do I check a .a file for multiply defined symbols?

11. solaris,apache,mod_perl,php: Make bombs symbol `Error' is multiply defined

12. Multiply defined symbols while linking with Workshop 6 ...

13. multiply defined symbols with -Bstatic, not with -Bdynamic