Multiple definition of xxx

R

Rob Amboss

Hi all

I try to link against a library "linktest" which contains the function
that I wanna link to. However, it seems that there is also the same
function defined in the /usr/bin/ld if i understand the errormessage
below correctly.

...//libtest.a(bn86-elf.o)(.text+0x860): In function `xxx':
: multiple definition of `test_words'
/tmp/cc1BVZOC.o(.text+0x0):test.c:83: first defined here
/usr/bin/ld: Warning: size of symbol `xxx' changed from 863 in
/tmp/cc1BVZOC.o to 1394 in ..//libtest.a(bn86-elf.o)
collect2: ld returned 1 exit status

Is there a way to tell the linker to take the function from the library
and ignore the other one in the usr/bin/ld?

Thanks!
 
A

Andrew Smallshaw

I try to link against a library "linktest" which contains the function
that I wanna link to. However, it seems that there is also the same
function defined in the /usr/bin/ld if i understand the errormessage
below correctly.

..//libtest.a(bn86-elf.o)(.text+0x860): In function `xxx':
: multiple definition of `test_words'
/tmp/cc1BVZOC.o(.text+0x0):test.c:83: first defined here
/usr/bin/ld: Warning: size of symbol `xxx' changed from 863 in
/tmp/cc1BVZOC.o to 1394 in ..//libtest.a(bn86-elf.o)
collect2: ld returned 1 exit status

The /usr/bin/ls in the errors above is ld identifying its output
so that you know that particular error is coming from ld (the
linker) rather than another phase of the build process. It is an
error _from_ ld, not _about_ ld.

Based on the other information you have supplied it appears that
the problem is that linktest is indeed defined twice, but the extra
definition is on or about line 83 of test.c. Take a look at it.
Hint: make sure that it is a _declaration_ and not a _definition_.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top