静态链接util-linux – 交叉编译(生成动态链接文件)
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了静态链接util-linux – 交叉编译(生成动态链接文件),小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2737字,纯文字阅读大概需要4分钟。
内容图文
我一直试图交叉编译util-linux for arm但我一直以动态链接的可执行文件结束,我不知道为什么会这样.我的目标是静态的.我在使用类似步骤的不同工具之前进行了交叉编译,并且它一直有效,所以这次我不知道我做错了什么.我正在使用Ubuntu 16.04.以下是我正在运行的命令:
export CC=arm-linux-gnueabi-gcc
export ac_cs_linux_vers=4
export CFLAGS=-static
export CPPFLAGS=-static
export LDFLAGS=-static
./configure --host=arm-linux LDFLAGS=-static --disable-shared --without-tinfo --without-ncurses --disable-ipv6 --disable-pylibmount --enable-static-programs=fdisk,sfdisk,whereis --prefix=/opt/util-linux/arm --bindir=/opt/util-linux/arm/bin --sbindir=/opt/util-linux/arm/sbin
正如你所看到的,我在每个我能想到的地方指定静态甚至重复“只是为了确保它理解我”并且在我运行configure脚本之后,这里是输出:
util-linux 2.28.2
prefix: /opt/util-linux/arm
exec prefix: ${prefix}
localstatedir: ${prefix}/var
bindir: /opt/util-linux/arm/bin
sbindir: /opt/util-linux/arm/sbin
libdir: ${exec_prefix}/lib
includedir: ${prefix}/include
usrbin_execdir: ${exec_prefix}/bin
usrsbin_execdir: ${exec_prefix}/sbin
usrlib_execdir: ${exec_prefix}/lib
compiler: arm-linux-gnueabi-gcc
cflags: -static
suid cflags:
ldflags: -static
suid ldflags:
Python: /usr/bin/python
Python version: 2.7
Python libs: ${exec_prefix}/lib/python2.7/site-packages
Bash completions: /usr/share/bash-completion/completions
Systemd support: no
Btrfs support: yes
warnings:
然后我做:
make fdisk
要么
make whereis
编译完成后,我做:
file fdisk
fdisk是刚刚创建的文件,并且:
fdisk: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.3, for GNU/Linux 3.2.0, BuildID[sha1]=369363ef8f8173a3a1c2edc178eb77255a2dc415, not stripped
正如你所看到的那样,“动态链接”.我一直在互联网上搜索,但我没有找到答案.我也这样做:
./configure --host=arm-linux LDFLAGS=-static --disable-shared --without-tinfo --without-ncurses --disable-ipv6 --disable-pylibmount --prefix=/opt/util-linux/arm --bindir=/opt/util-linux/arm/bin --sbindir=/opt/util-linux/arm/sbin
这与之前的配置命令完全相同,除了缺少“–enable-static-programs”参数,“默认情况下应该”将所有内容编译为静态,除非它没有.
我做错了什么或这是一个Makefile错误?
解决方法:
静态二进制文件使用.static扩展构建;在构建之后,我得到了
$file fdisk.static
fdisk.static: ELF 32-bit LSB executable, ARM, EABI5 version 1 (GNU/Linux), statically linked, for GNU/Linux 3.2.0, BuildID[sha1]=b51ec4b17f772b881d2a1eaefd368cfb96d0db12, not stripped
我只有这个
./configure --host=arm-linux-gnueabihf --enable-static-programs=fdisk
(你不需要任何FLAGS变量;在你的设置中用gnueabi替换gnueabihf,我只是用它,因为我已经有了一个工作的armhf交叉编译设置).
内容总结
以上是互联网集市为您收集整理的静态链接util-linux – 交叉编译(生成动态链接文件)全部内容,希望文章能够帮你解决静态链接util-linux – 交叉编译(生成动态链接文件)所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。