创建 docker :ubuntu 14.04
源码下载(指定版本下载 V8.25)
推荐1, 文件夹里面包含configure
文件,可以直接使用命令./configure&&make
编译,其他的比较麻烦,需要先安装依赖,然后使用./bootstrap &&./configure && make
编译(我使用这个方法编译最后失败了)
编译
- 解压(使用
链接1
下载coreutils-8.25.tar.xz
)
- 编译
./configure
报错:
configure: error: you should not run configure as root (set FORCE_UNSAFE_CONFIGURE=1 in environment to bypass this check) See `config.log’ for more details
解决方法:
./configure FORCE_UNSAFE_CONFIGURE=1
然后,
make
编译成功(编译生成的可执行文件都在文件夹coreutils-8.25\src
下)
- 指定编译器,编译选项
sudo ./configure CC="gcc" CXX="g++" CFLAGS="-O0" CXXFLAGS="-O0" FORCE_UNSAFE_CONFIGURE=1
编译32bit
sudo ./configure CC="gcc -m32" CXX="g++ -m32" CFLAGS="-O0" CXXFLAGS="-O0" FORCE_UNSAFE_CONFIGURE=1
-m32
生成32位机器的汇编代码;
-m64
生成64位机器汇编代码;
但是,报错:
checking for gcc... gcc -m32
checking whether the C compiler works... no
configure: error: in `/home/coreutils/coreutils-8.25':
configure: error: C compiler cannot create executables
See `config.log' for more details
查阅资料后,发现当在64位机器上编译出32位的可执行文件,需要先安装依赖,再编译
sudo apt-get install libc6-dev-i386
sudo ./configure CC="gcc -m32" CXX="g++ -m32" CFLAGS="-O0" CXXFLAGS="-O0" FORCE_UNSAFE_CONFIGURE=1
make
编译成功!