修改 libtool 项目 (Makefile) 以调用更正的链接器命令?

Modifying a libtool project (Makefile) so a corrected linker command is invoked?

提问人:sdbbs 提问时间:1/11/2023 更新时间:1/11/2023 访问量:64

问:

我正在尝试在 Windows 上的 Cygwin 下从 git 构建 GNU gettext;构建过程坏了,我找到了一个修复它的命令 - 但现在我不知道如何“修补”它,所以构建过程继续进行。

我遵循了官方的 INSTALL.windows,选项“1) 本机二进制文件,使用 mingw 工具链构建。自从写完之后,有些事情发生了变化,所以这些天对我来说是一个有效的配置行 - 注意我也想要一个静态构建:

./configure --enable-static --host=x86_64-w64-mingw32 --prefix=/usr/x86_64-w64-mingw32/sys-root/mingw \
  CC=x86_64-w64-mingw32-gcc \
  CXX=x86_64-w64-mingw32-g++ \
  CPPFLAGS="-I/usr/x86_64-w64-mingw32/sys-root/mingw/include -Wall" \
  LDFLAGS="-L/usr/x86_64-w64-mingw32/sys-root/mingw/lib"

现在,做最终崩溃了:make

make[2]: Entering directory '/cygdrive/c/src/gettext_git/gettext-runtime/intl'
/bin/sh ./libtool  --tag=CC   --mode=link x86_64-w64-mingw32-gcc -fvisibility=hidden  -g -O2 -Wl,--export-all-symbols -ladvapi32 -no-undefined -export-symbols-regex '^([^_]|_[^l]|_l[^i]|_li[^b]|_lib[^i]|_libi[^n]|_libin[^t]|_libint[^l]|_libintl[^_]).*' -version-info 11:0:3 -rpath /usr/x86_64-w64-mingw32/sys-root/mingw/lib -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib -o libintl.la  bindtextdom.lo dcgettext.lo dgettext.lo gettext.lo finddomain.lo hash-string.lo loadmsgcat.lo localealias.lo textdomain.lo l10nflist.lo explodename.lo dcigettext.lo dcngettext.lo dngettext.lo ngettext.lo plural.lo plural-exp.lo langprefs.lo log.lo printf.lo setlocale.lo version.lo osdep.lo intl-compat.lo gnulib-lib/libgnu.la libintl.res.lo
libtool: link: rm -fr  .libs/libintl.dll.a .libs/libintl.exp
libtool: link: /usr/bin/x86_64-w64-mingw32-nm -B  .libs/bindtextdom.o .libs/dcgettext.o .libs/dgettext.o .libs/gettext.o .libs/finddomain.o .libs/hash-string.o .libs/loadmsgcat.o .libs/localealias.o .libs/textdomain.o .libs/l10nflist.o .libs/explodename.o .libs/dcigettext.o .libs/dcngettext.o .libs/dngettext.o .libs/ngettext.o .libs/plural.o .libs/plural-exp.o .libs/langprefs.o .libs/log.o .libs/printf.o .libs/setlocale.o .libs/version.o .libs/osdep.o .libs/intl-compat.o .libs/libintl.res.o   gnulib-lib/.libs/libgnu.a | /usr/bin/sed -n -e 's/^.*[     ]\([ABCDGIRSTW][ABCDGIRSTW]*\)[         ][      ]*\([_A-Za-z][_A-Za-z0-9]*\)$/\1 \2 \2/p' | /usr/bin/sed '/ __gnu_lto/d' | /usr/bin/sed -e '/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //' | sort | uniq > .libs/libintl.exp
libtool: link: /usr/bin/grep -E -e "^([^_]|_[^l]|_l[^i]|_li[^b]|_lib[^i]|_libi[^n]|_libin[^t]|_libint[^l]|_libintl[^_]).*" ".libs/libintl.exp" > ".libs/libintl.expT"
libtool: link: mv -f ".libs/libintl.expT" ".libs/libintl.exp"
libtool: link: if test DEF = "`/usr/bin/sed -n -e 's/^[  ]*//' -e '/^\(;.*\)*$/d' -e 's/^\(EXPORTS\|LIBRARY\)\([         ].*\)*$/DEF/p' -e q .libs/libintl.exp`" ; then cp .libs/libintl.exp .libs/libintl-8.dll.def; else echo EXPORTS > .libs/libintl-8.dll.def; cat .libs/libintl.exp >> .libs/libintl-8.dll.def; fi
libtool: link:  x86_64-w64-mingw32-gcc -shared .libs/libintl-8.dll.def  .libs/bindtextdom.o .libs/dcgettext.o .libs/dgettext.o .libs/gettext.o .libs/finddomain.o .libs/hash-string.o .libs/loadmsgcat.o .libs/localealias.o .libs/textdomain.o .libs/l10nflist.o .libs/explodename.o .libs/dcigettext.o .libs/dcngettext.o .libs/dngettext.o .libs/ngettext.o .libs/plural.o .libs/plural-exp.o .libs/langprefs.o .libs/log.o .libs/printf.o .libs/setlocale.o .libs/version.o .libs/osdep.o .libs/intl-compat.o .libs/libintl.res.o  -Wl,--whole-archive gnulib-lib/.libs/libgnu.a -Wl,--no-whole-archive  -ladvapi32 -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib  -g -O2 -Wl,--export-all-symbols   -o .libs/libintl-8.dll -Wl,--enable-auto-image-base -Xlinker --out-implib -Xlinker .libs/libintl.dll.a
/usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: .libs/localealias.o: in function `read_alias_file':
/cygdrive/c/src/gettext_git/gettext-runtime/intl/./localealias.c:241: undefined reference to `_libintl_relocate2'
/usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: .libs/printf.o: in function `libintl_vfprintf':
/cygdrive/c/src/gettext_git/gettext-runtime/intl/./printf.c:125: undefined reference to `_libintl_vasnprintf'
/usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: .libs/printf.o: in function `libintl_vsprintf':
/cygdrive/c/src/gettext_git/gettext-runtime/intl/./printf.c:187: undefined reference to `_libintl_vasnprintf'
/usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: /cygdrive/c/src/gettext_git/gettext-runtime/intl/./printf.c:187: undefined reference to `_libintl_vasnprintf'
/usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: .libs/printf.o: in function `libintl_vsnprintf':
/cygdrive/c/src/gettext_git/gettext-runtime/intl/./printf.c:242: undefined reference to `_libintl_vasnprintf'
/usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: .libs/printf.o: in function `libintl_vasprintf':
/cygdrive/c/src/gettext_git/gettext-runtime/intl/./printf.c:288: undefined reference to `_libintl_vasnprintf'
/usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: .libs/printf.o:/cygdrive/c/src/gettext_git/gettext-runtime/intl/./printf.c:288: more undefined references to `_libintl_vasnprintf' follow
/usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: .libs/printf.o: in function `_libintl_vasnwprintf':
/cygdrive/c/src/gettext_git/gettext-runtime/intl/gnulib-lib/vasnprintf.c:1873: undefined reference to `_libintl_printf_fetchargs'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:1591: libintl.la] Error 1
make[2]: Leaving directory '/cygdrive/c/src/gettext_git/gettext-runtime/intl'

不幸的是,我真的不知道如何使用 libtool,因为我真的很难理解它;但我可以确定这是失败的“编译”行:

x86_64-w64-mingw32-gcc -shared .libs/libintl-8.dll.def  .libs/bindtextdom.o .libs/dcgettext.o .libs/dgettext.o .libs/gettext.o .libs/finddomain.o .libs/hash-string.o .libs/loadmsgcat.o .libs/localealias.o .libs/textdomain.o .libs/l10nflist.o .libs/explodename.o .libs/dcigettext.o .libs/dcngettext.o .libs/dngettext.o .libs/ngettext.o .libs/plural.o .libs/plural-exp.o .libs/langprefs.o .libs/log.o .libs/printf.o .libs/setlocale.o .libs/version.o .libs/osdep.o .libs/intl-compat.o .libs/libintl.res.o  -Wl,--whole-archive gnulib-lib/.libs/libgnu.a -Wl,--no-whole-archive  -ladvapi32 -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib  -g -O2 -Wl,--export-all-symbols   -o .libs/libintl-8.dll -Wl,--enable-auto-image-base -Xlinker --out-implib -Xlinker .libs/libintl.dll.a

因此,通过-ing,反复试验,我最终发现缺少文件-,,,,(相对于'gettext-runtime/intl'目录) - 如果添加,则使上述编译行成功。修改后的行如下,在终端中独立运行时,它可以正常工作/构建,没有错误:grep.ognulib-lib/relocatable.ognulib-lib/vasnprintf.ognulib-lib/printf-args.ognulib-lib/printf-parse.o

x86_64-w64-mingw32-gcc -shared .libs/libintl-8.dll.def .libs/bindtextdom.o .libs/dcgettext.o .libs/dgettext.o .libs/gettext.o .libs/finddomain.o .libs/hash-string.o .libs/loadmsgcat.o .libs/localealias.o .libs/textdomain.o .libs/l10nflist.o .libs/explodename.o .libs/dcigettext.o .libs/dcngettext.o .libs/dngettext.o .libs/ngettext.o .libs/plural.o .libs/plural-exp.o .libs/langprefs.o .libs/log.o .libs/printf.o .libs/setlocale.o .libs/version.o .libs/osdep.o .libs/intl-compat.o .libs/libintl.res.o gnulib-lib/relocatable.o gnulib-lib/vasnprintf.o gnulib-lib/printf-args.o gnulib-lib/printf-parse.o -Wl,--whole-archive gnulib-lib/.libs/libgnu.a -Wl,--no-whole-archive -ladvapi32 -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib -g -O2 -Wl,--export-all-symbols -o .libs/libintl-8.dll -Wl,--enable-auto-image-base -Xlinker --out-implib -Xlinker .libs/libintl.dll.a

嗯,这很好;在大多数项目中,如果我遇到这样的点,构建中断,然后我发现我从构建违规文件的终端运行的传递调用 - 通常我可以再次输入,构建过程继续。make

不在这里 - 一旦构建过程 (make) 进入“gettext-runtime/intl”,它就会删除所有内容并开始从头开始重建。该死。

好吧,这意味着我至少必须以某种方式修改 Makefile;我找不到 Makefile 中与该行对应的内容,但我认为一旦 make 进入目录,它就会由第一行触发 - 这是 ,我认为 Makefile 中的此条目触发了一个:x86_64-w64-mingw32-gcc -shared .../bin/sh ./libtool --tag=CC --mode=link ...

libintl.la: $(libintl_la_OBJECTS) $(libintl_la_DEPENDENCIES) $(EXTRA_libintl_la_DEPENDENCIES)
    $(AM_V_CCLD)$(libintl_la_LINK) $(am_libintl_la_rpath) $(libintl_la_OBJECTS) $(libintl_la_LIBADD) $(LIBS)

首先,我尝试在此处输入对象:gnulib-lib/relocatable.o

libintl.la: $(libintl_la_OBJECTS) $(libintl_la_DEPENDENCIES) $(EXTRA_libintl_la_DEPENDENCIES)
$(AM_V_CCLD)$(libintl_la_LINK) $(am_libintl_la_rpath) $(libintl_la_OBJECTS) gnulib-lib/relocatable.o gnulib-lib/vasnprintf.o gnulib-lib/printf-args.o gnulib-lib/printf-parse.o $(libintl_la_LIBADD) $(LIBS)

此操作失败,并显示:

libtool:   error: cannot build libtool library 'libintl.la' from non-libtool objects on this host: gnulib-lib/relocatable.o gnulib-lib/vasnprintf.o gnulib-lib/printf-args.o gnulib-lib/printf-parse.o

好吧,该死的,你。

原来,这些对象也有 .lo 版本,所以我尝试了:

libintl.la: $(libintl_la_OBJECTS) $(libintl_la_DEPENDENCIES) $(EXTRA_libintl_la_DEPENDENCIES)
$(AM_V_CCLD)$(libintl_la_LINK) $(am_libintl_la_rpath) $(libintl_la_OBJECTS) gnulib-lib/relocatable.lo gnulib-lib/vasnprintf.lo gnulib-lib/printf-args.lo gnulib-lib/printf-parse.lo $(libintl_la_LIBADD) $(LIBS)

现在,这种拥有 - 但是,额外的对象对象被完全忽略,我在这篇文章的开头得到了完全相同的链接错误:.lo

...
/bin/sh ./libtool  --tag=CC   --mode=link x86_64-w64-mingw32-gcc -fvisibility=hidden  -g -O2 -Wl,--export-all-symbols -ladvapi32 -no-undefined -export-symbols-regex '^([^_]|_[^l]|_l[^i]|_li[^b]|_lib[^i]|_libi[^n]|_libin[^t]|_libint[^l]|_libintl[^_]).*' -version-info 11:0:3 -rpath /usr/x86_64-w64-mingw32/sys-root/mingw/lib -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib -o libintl.la  bindtextdom.lo dcgettext.lo dgettext.lo gettext.lo finddomain.lo hash-string.lo loadmsgcat.lo localealias.lo textdomain.lo l10nflist.lo explodename.lo dcigettext.lo dcngettext.lo dngettext.lo ngettext.lo plural.lo plural-exp.lo langprefs.lo log.lo printf.lo setlocale.lo version.lo osdep.lo intl-compat.lo gnulib-lib/relocatable.lo gnulib-lib/vasnprintf.lo gnulib-lib/printf-args.lo gnulib-lib/printf-parse.lo gnulib-lib/libgnu.la libintl.res.lo
libtool: link: rm -fr  .libs/libintl.dll.a .libs/libintl.exp
libtool: link: /usr/bin/x86_64-w64-mingw32-nm -B  .libs/bindtextdom.o .libs/dcgettext.o .libs/dgettext.o .libs/gettext.o .libs/finddomain.o .libs/hash-string.o .libs/loadmsgcat.o .libs/localealias.o .libs/textdomain.o .libs/l10nflist.o .libs/explodename.o .libs/dcigettext.o .libs/dcngettext.o .libs/dngettext.o .libs/ngettext.o .libs/plural.o .libs/plural-exp.o .libs/langprefs.o .libs/log.o .libs/printf.o .libs/setlocale.o .libs/version.o .libs/osdep.o .libs/intl-compat.o .libs/libintl.res.o   gnulib-lib/.libs/libgnu.a | /usr/bin/sed -n -e 's/^.*[     ]\([ABCDGIRSTW][ABCDGIRSTW]*\)[         ][      ]*\([_A-Za-z][_A-Za-z0-9]*\)$/\1 \2 \2/p' | /usr/bin/sed '/ __gnu_lto/d' | /usr/bin/sed -e '/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //' | sort | uniq > .libs/libintl.exp
libtool: link: /usr/bin/grep -E -e "^([^_]|_[^l]|_l[^i]|_li[^b]|_lib[^i]|_libi[^n]|_libin[^t]|_libint[^l]|_libintl[^_]).*" ".libs/libintl.exp" > ".libs/libintl.expT"
libtool: link: mv -f ".libs/libintl.expT" ".libs/libintl.exp"
libtool: link: if test DEF = "`/usr/bin/sed -n -e 's/^[  ]*//' -e '/^\(;.*\)*$/d' -e 's/^\(EXPORTS\|LIBRARY\)\([         ].*\)*$/DEF/p' -e q .libs/libintl.exp`" ; then cp .libs/libintl.exp .libs/libintl-8.dll.def; else echo EXPORTS > .libs/libintl-8.dll.def; cat .libs/libintl.exp >> .libs/libintl-8.dll.def; fi
libtool: link:  x86_64-w64-mingw32-gcc -shared .libs/libintl-8.dll.def  .libs/bindtextdom.o .libs/dcgettext.o .libs/dgettext.o .libs/gettext.o .libs/finddomain.o .libs/hash-string.o .libs/loadmsgcat.o .libs/localealias.o .libs/textdomain.o .libs/l10nflist.o .libs/explodename.o .libs/dcigettext.o .libs/dcngettext.o .libs/dngettext.o .libs/ngettext.o .libs/plural.o .libs/plural-exp.o .libs/langprefs.o .libs/log.o .libs/printf.o .libs/setlocale.o .libs/version.o .libs/osdep.o .libs/intl-compat.o .libs/libintl.res.o  -Wl,--whole-archive gnulib-lib/.libs/libgnu.a -Wl,--no-whole-archive  -ladvapi32 -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib  -g -O2 -Wl,--export-all-symbols   -o .libs/libintl-8.dll -Wl,--enable-auto-image-base -Xlinker --out-implib -Xlinker .libs/libintl.dll.a
/usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: .libs/localealias.o: in function `read_alias_file':
/cygdrive/c/src/gettext_git/gettext-runtime/intl/./localealias.c:241: undefined reference to `_libintl_relocate2'
...

啊啊啊!!!!!啊1!

那么 -- 我怎样才能破解我在这个项目中的更改,以便构建至少在这个失败的步骤中成功?(作为参考,这是我在此目录中生成的 Makefile

makefile 链接器 cygwin gettext libtool

评论

1赞 MadScientist 1/12/2023
我建议您在gettext邮件列表上提问。

答: 暂无答案