1

我正在交叉编译开放的 VMWare 工具。我预编译了 glib,并设置了PKG_CONFIG_PATH变量来链接它们。我在链接阶段遇到以下错误。

libtool: link: warning: library `/u/git/extlib_vmtools/usr/local/lib/libgthread-2.0.la' was moved.
/bin/grep: /usr/local/lib/libglib-2.0.la: No such file or directory
/bin/sed: can't read /usr/local/lib/libglib-2.0.la: No such file or directory
libtool: link: `/usr/local/lib/libglib-2.0.la' is not a valid libtool archive
make[2]: *** [libhgfs.la] Error 1
make[2]: Leaving directory `/u/git/extlib_vmtools/src/open-vm-tools-11.0.0-14549434/libhgfs'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/u/git/extlib_vmtools/src/open-vm-tools-11.0.0-14549434'

我关注了这篇有用的帖子(DESTDIR 和 PREFIX of make),但我认为我遗漏了一些东西。我没有--prefix为任何模块设置,因为我想在部署时使用默认的目录结构。

glib 编译(低层模块):

./configure --host=${CROSS_COMPILE_HOST}
make
make install DESTDIR=/home/xport/

open-vmware-tools 编译(上层模块):

export PKG_CONFIG_SYSROOT_DIR="/home/xport/"
export PKG_CONFIG_PATH="/home/xport/usr/local/lib/pkgconfig"
autoreconf -i
./configure --host=${CROSS_COMPILE_HOST} --enable-lib64=no --without-kernel-modules --without-pam --disable-vgauth --without-x --without-gtk3 --without-gtk2 --without-gtkmm3 --without-gtkmm --enable-resolutionkms=no --enable-deploypkg=no
make
make install DESTDIR=/home/xport # <-- I don't even get here

在我设置PKG_CONFIG_PATH变量之前,由于缺少 .h 文件,第二次 make 失败......所以我知道.pc链接有效。我错过了什么?谢谢 !

4

1 回答 1

1
./configure --host=${CROSS_COMPILE_HOST} ...

您需要将两者都设置--build--hostAutoconf 错误。假设您正在为 ARMv7l 构建,例如:

./configure --host=$(config.guess) --build=armv7l-unknown-linux-gnueabihf

以下对我来说看起来不错,假设/home/xport/usr/local/lib/pkgconfig是有效的并且是拱门的和文件/home/xport/usr/local的位置。include/lib/

export PKG_CONFIG_PATH="/home/xport/usr/local/lib/pkgconfig"

我不确定接下来会发生什么。它也缺少一个--build. 而且我习惯于--sysroot在交叉编译时看到:

./configure --host=${CROSS_COMPILE_HOST} \
    --enable-lib64=no --without-kernel-modules --without-pam --disable-vgauth \
    --without-x --without-gtk3 --without-gtk2 --without-gtkmm3 --without-gtkmm \
    --enable-resolutionkms=no --enable-deploypkg=no

CFLAGS并且CXXFLAGS可能应该包括--sysroot. 也许是这样的:

./configure --host=$(config.guess) --build=armv7l-unknown-linux-gnueabihf \
    --sysroot="/home/xport/usr/local" --enable-lib64=no --without-kernel-modules ...

或者:

    CFLAGS="--sysroot=/home/xport/usr/local" \
    CXXFLAGS="--sysroot=/home/xport/usr/local" \
./configure --host=$(config.guess) --build=armv7l-unknown-linux-gnueabihf \
    --enable-lib64=no --without-kernel-modules ...

DESTDIR用于分期。这看起来不错:

make install DESTDIR=/home/xport/

如果您打算从/home/xport/目录运行,那么您应该考虑将以下内容添加到LDFLAGS

# 64-bit Fedora
-Wl,--enable-new-dtags -Wl,-R,'$$ORIGIN/../lib64'
# Most others
-Wl,--enable-new-dtags -Wl,-R,'$$ORIGIN/../lib'

所以也许是这样的:

    CFLAGS="--sysroot=/home/xport/usr/local" \
    CXXFLAGS="--sysroot=/home/xport/usr/local" \
    LDFLAGS="-Wl,--enable-new-dtags -Wl,-R,'$$ORIGIN/../lib'" \
./configure --host=$(config.guess) --build=armv7l-unknown-linux-gnueabihf \
    --enable-lib64=no --without-kernel-modules ...

$ORIGIN基于 -based 的运行路径是使分阶段安装DESTDIR工作的原因。

双美元登录$$ORIGIN是由于 Makefiles。双美元符号是转义美元符号的方法,因此它可以正确地通过makefile。

另请参阅如何在 Makefile 中正确包含 -Wl、-rpath、$ORIGIN 链接器参数?


config.guess为您提供 Autoconf 三元组:

$ /usr/share/libtool/build-aux/config.guess
x86_64-pc-linux-gnu

如果您没有config.guesson-path,请在以下位置检查/usr/share

$ find /usr/share -name config.guess
/usr/share/misc/config.guess
/usr/share/libtool/config/config.guess
/usr/share/automake-1.14/config.guess

另请参阅Autoconf 手册中的2.2.8 交叉编译:

交叉编译是在一个平台上构建将在另一个平台上运行的二进制文件。在谈到交叉编译时,重要的是要区分执行编译的构建平台和预期运行生成的可执行文件的主机平台。以下配置选项用于指定它们中的每一个:

--build=构建

     构建包的系统。

--主机=主机

     构建程序和库将运行的系统。

再往下一点:

--host 和 --build 选项通常是我们交叉编译所需要的。唯一的例外是如果正在构建的包本身就是一个交叉编译器:我们需要第三个选项来指定它的目标架构。

--目标=目标

     构建编译器工具时:工具将为其创建输出的系统。


关于评论“我什至没有到达这里”

make
make install DESTDIR=/home/xport # <-- I don't even get here

您需要显示运行时遇到的编译错误make

于 2019-12-17T16:37:24.647 回答