aMule Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're back! (IN POG FORM)

Author Topic: undefined reference to `unlink_if_ordinary'  (Read 4998 times)

amelcon

  • Approved Newbie
  • *
  • Karma: 1
  • Offline Offline
  • Posts: 9
undefined reference to `unlink_if_ordinary'
« on: May 13, 2006, 12:19:40 AM »

Aparently amule 2.1.1 fails in compilation when using binutils 2.16;
it does not seem to be a compiler related problem since I get the same
error with gcc3.3 and gcc4.0.3;
The final link process gives:

/system/binutils2.16/lib/libbfd.a(cache.o): In function `bfd_open_file':
/home/amelcon/packages/tmp/binutils-2.16.1/bfd/cache.c:440: undefined reference to `unlink_if_ordinary'
collect2: ld returned 1 exit status
make[3]: *** [amule] Error 1
make[3]: Leaving directory `/home/amelcon/packages/tmp/aMule-2.1.1/src'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/amelcon/packages/tmp/aMule-2.1.1/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/amelcon/packages/tmp/aMule-2.1.1'
make: *** [all] Error 2
Logged
amelcon

Gerd78

  • Hero Member
  • *****
  • Karma: 9
  • Offline Offline
  • Posts: 681
Re: undefined reference to `unlink_if_ordinary'
« Reply #1 on: May 13, 2006, 12:52:09 AM »

I have "unlink_if_ordinary" in my libiberty.a, which is a recursive dependency of libbfd and part of the binutils package. Please double-check that the ./configure script picks up "-liberty" correctly and, most importantly, that it picks up the right one. This could be the reason because your information looks like you have built the binutils yourself, so there might be a conflict with the previously installed copy.

If it doesn't work that way, I can tell you a work-around to build aMule without libbfd usage.
Logged

amelcon

  • Approved Newbie
  • *
  • Karma: 1
  • Offline Offline
  • Posts: 9
Re: undefined reference to `unlink_if_ordinary'
« Reply #2 on: May 13, 2006, 01:11:11 AM »

Yes, the problem might be related to this; I have checked actually that I have
one libiberty.a belonging to gcc4.0.3 (linked in /usr/local/lib) and another
libiberty.a belonging to binutils (linked to /usr/lib);

the configure script seems to pick -liberty, since in confing.log I see a line:

BFD_LIB='-lbfd -liberty'

what do I have to do with the two different libiberty.a?

thanks,
Logged
amelcon

Gerd78

  • Hero Member
  • *****
  • Karma: 9
  • Offline Offline
  • Posts: 681
Re: undefined reference to `unlink_if_ordinary'
« Reply #3 on: May 13, 2006, 01:16:31 AM »

Instead of running
Code: [Select]
makerun
Code: [Select]
make BFD_LIB="/absolute/path/to/libbfd.a /absolute/path/to/libiberty.a"like this, for example:
Code: [Select]
make BFD_LIB="/usr/lib/libbfd.a /usr/lib/libiberty.a"or
Code: [Select]
make BFD_LIB="/usr/local/lib/libbfd.a /usr/local/lib/libiberty.a"to make sure that libbfd and libiberty are taken from the same package.

If it's still not working that way, you can disable libbfd usage entirely like this:

- make sure autoconf, automake, libtool and friends are installed
- in configure.ac, delete or comment the CHECK_BFD line
- run ./autogen.sh
- build as usual
Logged

amelcon

  • Approved Newbie
  • *
  • Karma: 1
  • Offline Offline
  • Posts: 9
Re: undefined reference to `unlink_if_ordinary'
« Reply #4 on: May 13, 2006, 02:14:57 AM »

Thank you;
I would like to describe you few checks that I have done in case they are of any
use to you.

If I compile binutils2.14 with gcc3.3 and amule with gcc3.3 a simple "make" works, eventhough I have two versions of libiberty.a (apparently they behave the same),
and amule runs fine.

If I compile binutils 2.16 with gcc2.0.4 and amule with gcc2.0.4 I still have the
two versions of libiberty.a (one from binutils and one from gcc); now the 'make'
fails with the: undefined reference to `unlink_if_ordinary' error; apparently now
the libraries are incompatible. But as you
said, the: make BFD_LIB="/usr/lib/libbfd.a /usr/lib/libiberty.a" works since now
it uses both libraries from binutils2.16; in this case amule runs also fine. So the
problem is solved; thank you;

I would like to ask you two side questions that are not amule (but sorry I don't
want to abuse you):
1.-Why binutils and gcc comes with their own different libiberty.a library?
2.-You said that you libiberty.a library had "unlink_if_ordinary"; How can
anyone obtain this sort of information from a library?

again, many thanks
Logged
amelcon

Gerd78

  • Hero Member
  • *****
  • Karma: 9
  • Offline Offline
  • Posts: 681
Re: undefined reference to `unlink_if_ordinary'
« Reply #5 on: May 13, 2006, 02:41:26 AM »

Quote
Originally posted by amelcon
1.-Why binutils and gcc comes with their own different libiberty.a library?
Libiberty is a collection of several mostly unrelated utility functions. It comes with both binutils and gcc because both of them use it and it's not available as a stand-alone package.

Most Linux Distributors remove the copy that comes with gcc because having multiple copies of the same library is unnecessary and can sometimes even cause build problems, as it did for you.

The reason why the copy from binutils works for you and the copy from gcc doesn't is that aMule actually doesn't use libiberty directly; it uses libbfd from binutils which in turn uses libiberty, and for some reason, that seems to work only with the binutils-bundled copy.
Quote
2.-You said that you libiberty.a library had "unlink_if_ordinary"; How can
anyone obtain this sort of information from a library?
You can use the "nm" utility to find this information:
Code: [Select]
# nm /usr/lib/libiberty.a 2> /dev/null | grep unlink_if_ordinary
00000000 T unlink_if_ordinary
Logged

amelcon

  • Approved Newbie
  • *
  • Karma: 1
  • Offline Offline
  • Posts: 9
Re: undefined reference to `unlink_if_ordinary'
« Reply #6 on: May 13, 2006, 10:38:06 AM »

Thank you again.

I checked that `unlink_if_ordinary' is not in binutils2.14 and not in gcc3.3; that is
why the mixing of the libraries works in this case for amule compilation.

However, `unlink_if_ordinary' is in binutils2.16 and not in gcc4.0.3; that is why the
mixing produces problems. So I have removed 'libiberty.a' from the gcc copy
as you suggested, and now the standard 'make' works for amule;

thank you again for your teaching,
Logged
amelcon