bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: rpl_free undefined


From: Bruno Haible
Subject: Re: rpl_free undefined
Date: Tue, 03 May 2022 04:24:36 +0200

Reuben Thomas wrote:
> I have done this on branch gnulib-oddity:
> https://github.com/rrthomas/libpaper/tree/gnulib-oddity
> (I checked in a dist tarball.)

Thanks; got it.

> However, updating gnulib seems to have fixed the problem.

OK, so our effort from April 2021 to June 2021 fixed the problem;
recall that you initiated that through
<https://lists.gnu.org/archive/html/bug-gnulib/2021-04/msg00104.html>.

> But there is a new problem: when I build from the tarball with the updated
> gnulib on MSYS I get multiple definition errors for relocate and relocate2:
> 
>   CCLD     paper.exe
> /usr/lib/gcc/x86_64-pc-msys/11.2.0/../../../../x86_64-pc-msys/bin/ld:
> ../src/libgnu/.libs/libgnupaper.a(relocatable.o): in function
> `set_relocation_prefix':
> /home/rrt/libpaper-test/libpaper-1.2.0/src/libgnu/relocatable.c:169:
> multiple definition of `set_relocation_prefix';
> ../lib/.libs/libpaper.a(relocatable.o):/home/rrt/libpaper-test/libpaper-1.2.0/libgnu/relocatable.c:169:
> first defined here
> /usr/lib/gcc/x86_64-pc-msys/11.2.0/../../../../x86_64-pc-msys/bin/ld:
> ../src/libgnu/.libs/libgnupaper.a(relocatable.o): in function `relocate':
> /home/rrt/libpaper-test/libpaper-1.2.0/src/libgnu/relocatable.c:482:
> multiple definition of `relocate';
> ../lib/.libs/libpaper.a(relocatable.o):/home/rrt/libpaper-test/libpaper-1.2.0/libgnu/relocatable.c:482:
> first defined here
> /usr/lib/gcc/x86_64-pc-msys/11.2.0/../../../../x86_64-pc-msys/bin/ld:
> ../src/libgnu/.libs/libgnupaper.a(relocatable.o): in function `relocate2':
> /home/rrt/libpaper-test/libpaper-1.2.0/src/libgnu/relocatable.c:597:
> multiple definition of `relocate2';
> ../lib/.libs/libpaper.a(relocatable.o):/home/rrt/libpaper-test/libpaper-1.2.0/libgnu/relocatable.c:597:
> first defined here
> collect2: error: ld returned 1 exit status
> 
> It works fine on mingw.

When building on mingw (without --enable-relocatable), I get link errors:

  CCLD     paper.exe
paper-paper.o: In function `main':
/home/bruno/libpaper-1.2.0/build-mingw64/src/../../src/paper.c:115: undefined 
reference to `set_program_name_and_installdir'
/home/bruno/libpaper-1.2.0/build-mingw64/src/../../src/paper.c:122: undefined 
reference to `get_full_program_name'
/home/bruno/libpaper-1.2.0/build-mingw64/src/../../src/paper.c:123: undefined 
reference to `compute_curr_prefix'
collect2: error: ld returned 1 exit status

This simply means that you need to protect a couple of lines of paper.c
with '#if ENABLE_RELOCATABLE'.

When building on mingw with --enable-relocatable, 'CCCLD paper.exe' works fine.
The following .o files define e.g. 'relocate2':
  libgnu/relocatable.o = libgnu/.libs/relocatable.o
  src/libgnu/relocatable.o = src/libgnu/.libs/relocatable.o
The two .o files are not identical: the second one defines
'compute_curr_prefix', the first one doesn't.

It appears that the MSYS linker attempts to link with both of these .o
files (inside .a libraries), whereas the mingw linker only takes the
second one. On mingw:
  $ x86_64-w64-mingw32-ld.exe --version
  GNU ld (GNU Binutils) 2.29.1.20171006

What's the `ld --version` in your MSYS?

Bruno






reply via email to

[Prev in Thread] Current Thread [Next in Thread]