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

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

Post by Super-Use » Sat, 24 Feb 2001 08:36:39



All,

I am sure an easy question (newbie) but I am trying to compile SUN's
ramdisk example driver, with:

cc -O -I/net/devi/usr/include -I. -D_KERNEL    -c -o /ramdisk.o
ramdisk.c
ld -r -o /ramdisk /ramdisk.o
cc -O -I/net/devi/usr/include -I. -D_KERNEL    -I/net/devi/usr/include
-I.   ramdisk.c /ramdisk   -o ramdisk
ld: fatal: symbol `_init' is multiply defined:
        (file /opt/SUNWspro/WS6U1/lib/crti.o and file ramdisk.o);
ld: fatal: symbol `_fini' is multiply defined:
        (file /opt/SUNWspro/WS6U1/lib/crti.o and file ramdisk.o);
ld: fatal: symbol `_init' is multiply defined:
        (file /opt/SUNWspro/WS6U1/lib/crti.o and file /ramdisk);
ld: fatal: symbol `_info' is multiply defined:
        (file ramdisk.o and file /ramdisk);
ld: fatal: symbol `_fini' is multiply defined:
        (file /opt/SUNWspro/WS6U1/lib/crti.o and file /ramdisk);
ld: fatal: File processing errors. No output written to ramdisk
make[1]: *** [ramdisk] Error 1
make[1]: Leaving directory `/opt/SUNWddk/src/drivers/ramdisk'
make: *** [ramdisk] Error 2

It looks like the crt library is getting pulled in, which will not work
for kernel space.

What is up, and how can I fix it?

Thx In Adv.

 
 
 

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

Post by Kenneth Ch » Sat, 24 Feb 2001 09:55:08



>I am sure an easy question (newbie) but I am trying to compile SUN's
>ramdisk example driver, with:

>cc -O -I/net/devi/usr/include -I. -D_KERNEL    -c -o /ramdisk.o
>ramdisk.c
>ld -r -o /ramdisk /ramdisk.o
>cc -O -I/net/devi/usr/include -I. -D_KERNEL    -I/net/devi/usr/include
>-I.   ramdisk.c /ramdisk   -o ramdisk

Why are you compiling ramdisk.c again?  You are done after the link.

 
 
 

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

Post by Doug Hocki » Sat, 24 Feb 2001 12:06:29



> >cc -O -I/net/devi/usr/include -I. -D_KERNEL    -c -o /ramdisk.o
> >ramdisk.c
> >ld -r -o /ramdisk /ramdisk.o
> >cc -O -I/net/devi/usr/include -I. -D_KERNEL    -I/net/devi/usr/include
> >-I.   ramdisk.c /ramdisk   -o ramdisk

> Why are you compiling ramdisk.c again?  You are done after the link.

Yep.

The second "cc" line is using cc (the compiler front end)
to do a compile and link with a single command
line.  Because you're using cc to invoke the link it assumes you
want a standalone executable and automatically includes crt and
several other libraries in the linker command line it generates
under the covers.  Most cc's
have a command line option to show you all the command lines
generated to get the job done.

The first two lines are all you need, the third command line
is unnecessary and does the wrong things for a driver.

-- Doug

 
 
 

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

Post by Kenneth Ch » Sat, 24 Feb 2001 12:16:24



>I am sure an easy question (newbie) but I am trying to compile SUN's
>ramdisk example driver, with:

BTW, you are probably already aware of this, but just in case:


 
 
 

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

Post by Casper H.S. Dik - Network Security Engine » Sat, 24 Feb 2001 18:53:53


[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]


>I am sure an easy question (newbie) but I am trying to compile SUN's
>ramdisk example driver, with:
>cc -O -I/net/devi/usr/include -I. -D_KERNEL    -c -o /ramdisk.o
>ramdisk.c

This gets you ramdisk.o

Quote:>ld -r -o /ramdisk /ramdisk.o

And here you are done.

(Uhm, you're not really compiling in /, are you?

Quote:>cc -O -I/net/devi/usr/include -I. -D_KERNEL    -I/net/devi/usr/include
>-I.   ramdisk.c /ramdisk   -o ramdisk

Looks like a second compile, this time to an application. This brings
in the runtime startup glue which you don't want.

Compile to .o and then link with ld.

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.

 
 
 

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

Post by Kenny McCorma » Sat, 24 Feb 2001 22:51:30





>>I am sure an easy question (newbie) but I am trying to compile SUN's
>>ramdisk example driver, with:

Just out of curiosity, where do you get this ramdisk.c example code?
 
 
 

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. What packages are for ToolTalk in Solaris 2.5.1?

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

4. Help for a newbie

5. ld: multiply defined symbol

6. Newbie: setting LOCALES

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

8. Is there a limit on shared memory size?

9. ld.so.1: /opt/bin/apache/httpd: fatal: ... symbol ap_make_sub_pool: referenced symbol not found

10. fatal: relocation error: file grep: symbol _init:

11. ld multiply defined error

12. : ld error: _tolower & _toupper multiply defined

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