STREAMS-Module: linking problems

STREAMS-Module: linking problems

Post by Thomas Leye » Sat, 11 Nov 2000 04:00:00



Hi there,

I'm trying to compile and link a streams-module with

Sun WorkShop 6 2000/04/07 C 5.1

it all worked fine, until I tried to link it with my
own static-build library. Now the linker keeps telling me
about the _fini and the _init symbols that are in it's opinion
multiply defined (once in my stuff and in crti.o, which I didn't
want to link it with...).

As this will be a kernel module I don't want the standard librarries to be
linked to it, so II tried to invoke the compilation and linking with the
-xnolib Flag... but it still keeps telling me about the same error...

==========compilation looked like===========
[sir-tl: src/null_module] <5> make
/solaris/WorkShop6.0/SUNWspro/bin/cc -c   -D_KERNEL -DSYSV -xnolib
-I.  null.c
/solaris/WorkShop6.0/SUNWspro/bin/cc   -D_KERNEL -DSYSV -xnolib
-I. null.o  -xnolib -Bstatic
ld: fatal: symbol `_fini' is multiply defined:
        (file /solaris/WorkShop6.0/SUNWspro/WS6/lib/crti.o and file
null.o);
ld: fatal: symbol `_init' is multiply defined:
        (file /solaris/WorkShop6.0/SUNWspro/WS6/lib/crti.o and file
null.o);
ld: fatal: File processing errors. No output written to a.out
*** Error code 1
make: Fatal error: Command failed for target `null'
==============================================

I already tried the advice I found in dejanews, to rename the _init and
_fini and #pragma myinit(init) it ...  

=========then compilation looked like========
[sir-tl: src/null_module]<22> make
/solaris/WorkShop6.0/SUNWspro/bin/cc -c   -D_KERNEL -I.  null.c
/solaris/WorkShop6.0/SUNWspro/bin/cc -D_KERNEL -I. null.o  -xnolib
Undefined                       first referenced
 symbol                             in file
qprocsoff                           null.o
mod_strmodops                       null.o
atexit
/solaris/WorkShop6.0/SUNWspro/WS6/lib/crt1.o
exit
/solaris/WorkShop6.0/SUNWspro/WS6/lib/crt1.o
mod_install                         null.o
qprocson                            null.o
putnext                             null.o
_exit
/solaris/WorkShop6.0/SUNWspro/WS6/lib/crt1.o
mod_info                            null.o
main
/solaris/WorkShop6.0/SUNWspro/WS6/lib/crt1.o
mod_remove                          null.o
ld: fatal: Symbol referencing errors. No output written to a.out
*** Error code 1
make: Fatal error: Command failed for target `null'
============================================

So I don't know how to tell the compiler just to take my own explicitely
named libraries and nothing else....

I'm grateful for any idea....

Thanks
        Thomas

 
 
 

STREAMS-Module: linking problems

Post by Philip Bro » Sat, 11 Nov 2000 04:00:00



>==========compilation looked like===========
>[sir-tl: src/null_module] <5> make
>/solaris/WorkShop6.0/SUNWspro/bin/cc -c   -D_KERNEL -DSYSV -xnolib
>-I.  null.c
>/solaris/WorkShop6.0/SUNWspro/bin/cc   -D_KERNEL -DSYSV -xnolib
>-I. null.o  -xnolib -Bstatic
>ld: fatal: symbol `_fini' is multiply defined:
>        (file /solaris/WorkShop6.0/SUNWspro/WS6/lib/crti.o and file

Why are you doing it this way, instead of using the makfiles that are in
the "sample drivers" archives?

to simplify things, you should link like this:

ld -r -o drivername file1.o file2.o ...

--
[Trim the no-bots from my address to reply to me by email!]
[ Do NOT email-CC me on posts. Pick one or the other.]

The word of the day is mispergitude

 
 
 

STREAMS-Module: linking problems

Post by Casper H.S. Dik - Network Security Engine » Sat, 11 Nov 2000 04:00:00


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


>As this will be a kernel module I don't want the standard librarries to be
>linked to it, so II tried to invoke the compilation and linking with the
>-xnolib Flag... but it still keeps telling me about the same error...

In general, linking kernel modules is the one time you use ld:

        ld -r -o kernel_mod *.o -l.....

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.