首先更新虛擬機下載源
sudo apt-get update
在安裝mysql時./configure容易出現錯誤error: No curses/termcap library found
原因是缺少ncurses安裝包
解決方法:
sudo apt-cache search ncurses
sudo apt-get install libncurses5-dev
如果要將庫移植到arm板上的話就需要下載ncurses包進行安裝
下載ncurses-5.9.tar.gz
ftp://ftp.gnu.org/gnu/ncurses/ncurses-5.9.tar.gz
先安裝ncurses
tar -xzvf ncurses-5.9.tar.gz
mkdir ncurses
cd ncurses-5.9/
./configure --prefix=/home/farsight/ncurses CC=arm-none-linux-gnueabi-gcc --host=arm-none-linux-gnueabi --enable-static --enable-shared
make
make install
安裝完成后,開始編譯mysql庫
首先下載mysql數據庫源碼//download.chinaunix.net/download.php?id=34712&ResourceID=7159
將源碼拷貝到虛擬機中并解壓,進入源碼文件
tar xzvf mysql-5.1.51.tar.gz
mkdir mysql
cd mysql-5.1.51/
修改文件中的configure配置文件(注釋掉不允許交叉編譯的部分)
修改配置文件:打開configure,可以使用gedit configure 分別在第26453行、 48175行、 48282行、 48485行附近有類似代碼:
if test "$cross_compiling" = yes; then
{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross
compiling See \`config.log' for more details." >&5
$as_echo "$as_me: error: cannot run test program while cross compiling See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }; }
Else
將這些代碼改為:
if test "$cross_compiling" = yes; then
echo “skip …..!”
#{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 #$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
#{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling See \`config.log' for more details." >&5
#$as_echo "$as_me: error: cannot run test program while cross compiling See \`config.log' for more details." >&2;}
#{ (exit 1); exit 1; }; }; }
Else
一定注意,這樣的代碼有4部分,要全部改掉
接下來進行庫的安裝
./configure --prefix=/home/farsight/mysql CC=arm-none-linux-gnueabi-gcc --host=arm-none-linux-gnueabi
--enable-static --enable-shared預處理
make 編譯(在這個過程中可能會出現一個錯誤,但是對庫的影響不大,可忽略)
make install 下載并安裝
完成后可在mysql中出現五個文件夾
需要將include文件夾下的文件考到/usr/include下進行編譯
將lib文件夾下的內容拷貝到arm板的lib文件夾下
在虛擬機中進行編譯時需要注意如果連接不到庫可在編譯時加入連接庫的方式
-L//home/farsight/mysql/lib/mysql