在Ubuntu 14.04上构建linuxbrew(homebrew)独立版本

时间:2015-09-29 22:59:24

标签: ubuntu installation homebrew linuxbrew

主要问题

我试图在Ubuntu 14.04.3 LTS上构建linuxbrew standalone installation,但原始链接中的脚本目前已被破坏。我理想的答案是一个可以一次性正确设置的脚本。我已经improved the script以更少的打嗝来运行。

目前修复脚本的进度

作为独立设置的一部分,在通过linuxbrew构建gcc时,我无法通过crti.o错误。但是,我找到了解释问题的一些资源:

我搜索了该文件,它就在那里!

find -name crti.o
./.linuxbrew/lib/crti.o
./.linuxbrew/Cellar/glibc/2.19/lib/crti.o

我目前正在为crtn.o发出以下编译错误:

/home/hbr/.linuxbrew/Cellar/binutils/2.25.1/x86_64-unknown-linux-gnu/bin/ld: cannot find crti.o: No such file or directory
/home/hbr/.linuxbrew/Cellar/binutils/2.25.1/x86_64-unknown-linux-gnu/bin/ld: cannot find -lc
/home/hbr/.linuxbrew/Cellar/binutils/2.25.1/x86_64-unknown-linux-gnu/bin/ld: cannot find crtn.o: No such file or directory
collect2: error: ld returned 1 exit status
make[3]: *** [libgcc_s.so] Error 1
make[3]: Leaving directory `/tmp/gcc20150929-3726-hif3of/gcc-5.2.0/build/x86_64-unknown-linux-gnu/libgcc'
make[2]: *** [all-stage1-target-libgcc] Error 2
make[2]: Leaving directory `/tmp/gcc20150929-3726-hif3of/gcc-5.2.0/build'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/tmp/gcc20150929-3726-hif3of/gcc-5.2.0/build'
make: *** [bootstrap] Error 2

基本上,在这一步,我需要弄清楚如何确保brew / linuxbrew / gcc编译命令知道在哪里找到它。我尝试将其添加到the script中的PATHLIBRARY_PATHLD_LIBRARY_PATH,但没有任何运气。因此,必须有其他方法来确保正确设置路径并找到目标文件。有什么想法吗?

注意:我最初在this github issue搜索了帮助,但他们目前无法解决这个问题。

更新

我认为在此linuxbrew gcc formula中可能需要一个linuxbrew案例来实现stackoverflow crti.o file missing中找到的解决方案之一。

这是原始homebrew gcc formula供参考。

1 个答案:

答案 0 :(得分:3)

我已使用解决方案更新了linuxbrew standalone installation说明。我还创建了一个更新的linuxbrew-standalone.sh,已在14.04进行了测试和工作,并在TODO条评论中列出了几个小注意事项。

# /bin/bash
set -e
set -u
set -x

cd $HOME

# TODO: The next ln -s line breaks cross compiling with multiarch, need an alternative!
#       source: https://stackoverflow.com/a/9004026/99379
sudo ln -s /usr/lib/x86_64-linux-gnu /usr/lib64
sudo apt-get update -y
sudo apt-get update --fix-missing -y
sudo apt-get install build-essential curl g++ git m4 ruby texinfo libbz2-dev libcurl4-openssl-dev libexpat-dev libncurses-dev zlib1g-dev gawk make patch tcl -y

unset LD_LIBRARY_PATH PKG_CONFIG_PATH HOMEBREW_CC
PATH=$HOME/.linuxbrew/bin:/usr/local/bin:/usr/bin:/bin
yes | ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/linuxbrew/go/install)"

# hang on here. you will have to press return
# note that even if brew doctor is a little unhappy we want to keep going
brew doctor || true

mkdir $HOME/.linuxbrew/lib
ln -s lib $HOME/.linuxbrew/lib64
ln -s $HOME/.linuxbrew/lib $HOME/.linuxbrew/lib64
ln -s /usr/lib64/libstdc++.so.6 /lib64/libgcc_s.so.1 $HOME/.linuxbrew/lib/
PATH=$HOME/.linuxbrew/lib:$PATH
export PATH
LIBRARY_PATH=$HOME/.linuxbrew/lib
export LIBRARY_PATH
LD_LIBRARY_PATH=$HOME/.linuxbrew/lib
export LD_LIBRARY_PATH

# before this, you may want to `brew edit glibc` to produce compatibility for your particular kernel, for example:
# "--enable-version=2.6.18"

#brew unlink gawk
brew install glibc
brew unlink glibc
brew install https://raw.githubusercontent.com/Homebrew/homebrew-dupes/master/zlib.rb
brew reinstall binutils
brew link glibc
brew install patchelf
brew install gcc --with-glibc --only-dependencies -v
# When tested gcc was working except for the linking step, that's why it is force-accepted with ||true
# TODO: make it so force accepting isn't necessary and errors are shown correctly
brew install gcc --with-glibc -v || true
rm -f $HOME/.linuxbrew/lib/{libstdc++.so.6,libgcc_s.so.1}
brew link gcc --overwrite
export HOMEBREW_CC=gcc

brew install bzip2 curl expat
brew install git --with-brewed-curl --with-brewed-openssl --without-tcl-tk
brew tap homebrew/dupes
brew install coreutils findutils gawk gnu-sed gnu-which grep libpng libxml2 libxslt make ncurses readline
#ln -s ncursesw/curses.h ncursesw/form.h ncursesw/ncurses.h ncursesw/term.h ncursesw/termcap.h $HOME/.linuxbrew/include/
#ln -s libncurses.a $HOME/.linuxbrew/lib/libcurses.a
#ln -s libncurses.so $HOME/.linuxbrew/lib/libcurses.so
brew install ruby
PATH=$HOME/.linuxbrew/bin:$HOME/.linuxbrew/sbin
brew install hello && brew test hello; brew remove hello

修复内容的主要行是sudo ln -s /usr/lib/x86_64-linux-gnu /usr/lib64,但这有一个警告,我对修复感兴趣,因为breaks cross compiling with multiarch