gccとかglibcとかのビルド

とりあえず貼っておく



export CC=/usr/bin/gcc

./configure -v --enable-languages=c --prefix=/home/ryo/dusr/ --enable-shared --disable-threads --enable-nls --program-suffix=-4.2 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-checking=release --build=i486-linux-gnu --target=i486-linux-gnu --with-newlib --with-headers=./newlib/libc/include/ --disable-shared

./configure -v --enable-languages=c --prefix=/home/ryo/dusr/ --enable-shared --disable-threads --enable-nls --program-suffix=-4.2 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-checking=release --build=i486-linux-gnu --target=newlib --with-newlib --with-headers=./newlib/libc/include/ --disable-shared

./configure -v --enable-languages=c --prefix=/home/ryo/dusr/ --enable-shared --disable-threads --enable-nls --program-suffix=-4.2 --enable-clocale=gnu --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --with-newlib --disable-shared --includedir=/home/ryo/download/gcc-4.2.3/newlib/libc/include/

./configure --prefix=/home/ryo/user_new/


ln sys/crt0.o crt0.o >/dev/null 2>/dev/null || cp sys/crt0.o crt0.o
cp: cannot stat `sys/crt0.o': No such file or directory

./configure --prefix=/home/ryo/user_new/ --includedir=/home/ryo/download/gcc-4.2.3/newlib/libc/include/ --libdir=/home/ryo/dusr/lib --target=linux

○標準ライブラリをつわないでやる
gcc -nostdlib $(target_install_dir)/lib/crt0.o progname.c -I $(target_install_dir)/include -L $(target_install_dir)/lib -lc -lm -lgcc

../configure -v --enable-languages=c,c++ --prefix=/home/ryo/dusrnew --disable-nls --disable-threads --program-suffix=-3.4.1 --target=i486-linux-gnu --with-newlib --with-headers=/home/ryo/download/gcc-3.4.1/newlib/libc/include/ --disable-shared --with-march=i386 2>&1 | tee configure.log


○ucLibcのビルド
#TARGET_i386=yに
#あとは、インストール先の指定とスレッドの無効化ぐらいしか設定するところはなかったと思う
#一回適当に設定してから、.configファイルを編集した方が速い
make oldconfig
#.configを編集
DDEBUG=y
に変更
#Rules.mkを編集
CC=gcc-4.2 -g

make 2>&1 | tee build.log
#make installがこけるので
cp -r /home/ryo/download/uClibc-0.9.28/lib /home/ryo/dusr_uc/
cp -r /home/ryo/download/uClibc-0.9.28/include /home/ryo/dusr_uc/

○ucLibcでビルドしてみる
gcc -nostdlib /home/ryo/dusr_uc/lib/crt1.o -L /home/ryo/dusr_uc/lib/ hello.c -o hello.out -Wall -lc -static /home/ryo/dusr_uc/lib/crti.o /home/ryo/dusr_uc/lib/crtn.o


○gcc3.2のビルド
export CC=/usr/bin/gcc-3.4
cd /usr/src
wget http://www.jp.kernel.org/pub/linux/kernel/v2.2/linux-2.2.0.tar.gz
tar xvzf linux-2.2.0.tar.gz
mv linux linux2.2
cd linux2.2
#みんなデフォルトでOK
make oldconfig
#念のため
make include/linux/version.h

MakefileのCFLAGSに/usr/src/linux2.2/include

make


./configure -v --enable-languages=c,c++ --prefix=/home/ryo/dusr/ --include-dir=/usr/src/linux2.2/include --enable-shared --libexecdir=/home/ryo/dusr/lib/ --without-included-gettext --disable-threads --enable-nls --program-suffix=-3.2 --enable-clocale=gnu --enable-mpfr --build=i386-linux-gnu --host=i386-linux-gnu --target=i386-linux-gnu

./configure -v --enable-languages=c,c++ --prefix=/home/ryo/dusr/ --enable-shared --libexecdir=/home/ryo/dusr/lib/ --without-included-gettext --disable-threads --disable-nls --program-suffix=-3.2 --build=i386-linux-gnu --host=i686-linux-gnu --target=i386-linux-gnu --with-headers=/usr/src/linux2.2/include/


○glibc2.2.5のビルド
export CC=/usr/bin/gcc
mv /bin/sh /bin/sh_back
ln -s /bin/bash /bin/sh
../configure --prefix=/home/ryo/dusr/ --libdir=/home/ryo/dusr/lib --libexecdir=/home/ryo/dusr/lib --with-arch=i686 --with-ld-shared="gcc -shared" --disable-sanity-checks


TLSとスレッドを無効にしてglibc2.7をビルドしてみる
#tlsとthreadがないと駄目だと怒られる
../configure --prefix=/home/ryo/dusr/ --libdir=/home/ryo/dusr/lib --libexecdir=/home/ryo/dusr/lib --with-arch=i686 --with-ld-shared="gcc -shared" --without-tls --without-__thread

○uClibcを使ってmy_video_captureをビルド
cc my_video_capture.c -o my_video_capture -Wall -lc -static -nostdlib /home/ryo/dusr_uc/lib/crt1.o -L/home/ryo/dusr_uc/lib/ `pkg-config glib-2.0 --cflags` /home/ryo/dusr_uc/lib/crti.o /home/ryo/dusr_uc/lib/crtn.o

  • > BEE上でも正しく動作。


○uClibcを使ってOpenCVをビルド
export CXXFLAGS="-Wall -fno-rtti -pipe -O3 -g -march=i686 -ffast-math -fomit-frame-pointer -nostdlib /home/ryo/dusr_uc/lib/crt1.o -L /home/ryo/dusr_uc/lib/ -lc /home/ryo/dusr_uc/lib/crti.o /home/ryo/dusr_uc/lib/crtn.o -static"
した後に
confirgure

○uClibcを使ってcapture_visionをビルド
●shared
#事前に/lib/* と/usr/lib/* のうち、/home/ryo/dusr/libにないものを全てコピー
libcXXXとかでuClibcのものでないものはリネームして潰しておく。

export LD_LIBRARY_PATH=/home/ryo/dusr_uc/:/home/ryo/dusr/lib/

gcc -g -I./include -I/home/ryo/dusr/include/opencv/ -o CaptureSystem ./capture/main.o ./capture/framedifferencing.o ./capture/time_count.o ./capture/camctrlthread.o ./capture/capture.o ./capture/camera.o ./capture/visca.o ./capture/queue.o -Wall -lcxcore -lcv -lhighgui -lcvaux -L/usr/X11R6/lib -L/usr/local/lib -L/usr/lib -lm -lX11 -t 2>&1 | tee build_shared.log 2>&1

  • > 成功・・・してないかな

●static

○CentOS2でmy_video_captureをビルド
ラップトップの/usr/lib/glib-2.0/include/
の内容をコピーして`pkg-config glib-2.0 --cflags`の代わりに-Iオプションでそこを指定


Debian Etchを試してみる
apt-get install binfmtc
apt-get install nfs-client
apt-get install ssh
apt-get install make
apt-get install pkg-config
apt-get install less
apt-get install emacs
apt-get install build-essential
apt-get install screen
apt-get install subversion
apt-get install zsh
apt-get install sudo
apt-get install fakeroot



apt-get install libglib2.0-dev
apt-get source libc6
apt-get build-dep libc6

dpkg-source -x glibc_2.3.6.ds1-13etch5.dsc

debian/rules
PREFIXを修正

debian/rules.d/build.mkに
--without-__thread --without-tls

debian/control
で必要そうなものだけ残す

dpkg-buildpackage -rfakeroot -rfakeroot -uc -b 2>&1 | tee build.log

途中でこけるけど気にせずに

#インストールする
cd buid-tree/libc-i386

config.makeのPREFIXを変更
slibdir を $(PREFIX)/lib
sysconfdir を $(PREFIX)/etc
rootsbindir を $(PREFIX)/sbin


make install 2>&1 | tee make_install.log

gcc_no_tlsというコマンドを作成して
それをCCに設定してビルドすればvideo_captureとかはオーケー

OpenCVDebian Etch上で普通にビルド
./configure --enable-static CXXFLAGS=-fno-stack-protector CPPFLAGS=-fno-stack-protector

★現状
capture visionを普通のgcc, glibc ,sharedでビルドすることには成功。
しかし、gcc_no_tlsを使ってstaticでビルドしようとすると、解決できないシンボルがいくつかある。
それぞれ-lオプションで指定して、必要な静的ライブラリを用意していやらなくてはいけないだろう。