我正在交叉编译开放的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 and 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变量之前,第二个make由于缺少.h文件而失败...因此,我知道.pc链接有效。 我想念什么? 谢谢!
答案 0 :(得分:1)
./configure --host=${CROSS_COMPILE_HOST} ...
由于Autoconf错误,您需要同时设置--build
和--host
。假设您正在为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
的运行路径是使用DESTDIR
进行分阶段安装的原因。
$$ORIGIN
中的双美元符号归因于Makefile。双重美元符号是一种避免美元符号逸出的方式,因此它可以正确地通过makefile。
另请参见How to include correctly -Wl,-rpath,$ORIGIN linker argument in a Makefile?
config.guess
为您提供Autoconf三元组:
$ /usr/share/libtool/build-aux/config.guess
x86_64-pc-linux-gnu
如果路径上没有config.guess
,请在/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 Cross-Compilation:
交叉编译是在一个平台上构建将在以下平台上运行的二进制文件 另一个平台。说到交叉编译,这一点很重要 区分编译所在的构建平台 执行,并在其上生成结果可执行文件的主机平台 有望运行。以下配置选项用于指定 他们每个人:
-build =构建
构建软件包的系统。
-host = host
将运行内置程序和库的系统。
再往下走:
--host和--build选项通常是我们所需要的 交叉编译。唯一的例外是如果正在构建的软件包是 本身是交叉编译器:我们需要第三个选项来指定其目标 建筑。
-target = target
编译编译器工具时:系统 工具将为此创建输出。
关于评论“我什至没有来到这里” :
make make install DESTDIR=/home/xport # <-- I don't even get here
您需要显示运行make
时遇到的编译错误。