選用較好的編譯器和較好的編譯器選項,這樣應用可提高性能,這個對大多數程序都非常重要
Mysql
這個形式主要是使用
http://www.cnblogs.com/hemhem/archive/2011/03/14/2087481.html
http://blog.csdn.net/bing19880122/article/details/5830650
http://flyingdutchman.iteye.com/blog/1901149
MySQL cMake http://waynerqiu.com/7/153.html
http://www.cmake.org/
http://www.cnblogs.com/2018/p/3091616.html
mysql
http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html
http://dev.mysql.com/doc/refman/5.6/en/environment-variables.html
環境變量和可以進行配置
如下是一個實例
#CMAKE_BUILD_TYPE Debug:-g Release:-O2 RelWithDebInfo:-O2 -g MinSizeRel:-Os
#WITH_EMBEDDED_SERVER Whether to build the libmysqld embedded server library.
#WITH_PARTITION_STORAGE_ENGINE
#-DWITH_ASAN=1 \ #must gcc > 4.5
#DENABLE_DOWNLOADS google MOCK test
cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DCMAKE_BUILD_TYPE=Release \
-DSYSCONFDIR=/etc \
-DINSTALL_SBINDIR=/usr/local/mysql/bin \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_TCP_PORT=3306 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EMBEDDED_SERVER=0 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=0 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=0 \
-DWITH_MEMORY_STORAGE_ENGINE=0 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=0 \
-DWITH_EXTRA_CHARSETS=none \
-DWITH_DEBUG=0 \
# -DWITH_ASAN=1 \
# -DENABLE_DOWNLOADS=0 \
#end of cmake
注意
http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-4.8.2/gcc-4.8.2.tar.gz 從這下載
使用如下的腳本可以進行升級
#!/bin/bash
# gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5.1)
:<<EOF
ftp://gcc.gnu.org/pub/gcc/infrastructure/
GNU Multiple Precision Library (GMP) version 4.3.2 (or later)
MPFR Library version 2.4.2 (or later)
MPC Library version 0.8.1 (or later)
EOF
gccver=4.8.2
gmpver=4.3.2
mpfrver=2.4.2
mpcver=0.8.1
# where you put the downloaded source packages
pkgdir=.
# where you will build gcc
rootdir=gcc-${gccver}
# where you want to install gcc
prefix=/opt/gcc-${gccver}
# the languages you want gcc to support
langs=c,c++
#0 unpack file
:<<EOF
#Create a new directory on a disk with plenty of space and unpack the sources there:
mkdir -p ${rootdir}
tar xzf ${pkgdir}/gcc-${gccver}.tar.gz
tar xjf ${pkgdir}/gmp-${gmpver}.tar.bz2
tar xjf ${pkgdir}/mpfr-${mpfrver}.tar.bz2
tar xzf ${pkgdir}/mpc-${mpcver}.tar.gz
#Next, move the prerequisite sources into the gcc source directory:
mv gmp-${gmpver} ${rootdir}/gmp
mv mpfr-${mpfrver} ${rootdir}/mpfr
mv mpc-${mpcver} ${rootdir}/mpc
EOF
#
#1.1 build on source dir
pushd ${rootdir}
#make clean
#
./configure --prefix=${prefix} --enable-languages=${langs} --disable-multilib
make
make install
popd
#1.2 build on other dir
:<<EOF
#Now create a build directory and change to it
mkdir -p objdir
cd objdir
#Now configure gcc:
mkdir -p ${prefix}
../${rootdir}/configure --prefix=${prefix} --enable-languages=${langs} --disable-multilib
#configure --prefix=/opt/gcc-4.8.2 --enable-languages=c,c++
#Now build gcc:
make
#Finally, install gcc:
make install
#fixincludes
cd ..
EOF
###
#2
#
sudo update-alternatives --remove-all gcc
sudo update-alternatives --remove-all g++
sudo update-alternatives --install /usr/bin/gcc gcc /opt/gcc-4.8.2/bin/gcc 40
sudo update-alternatives --install /usr/bin/g++ g++ /opt/gcc-4.8.2/bin/g++ 40
#
sudo update-alternatives --config gcc
sudo update-alternatives --config g++
#3
rm -f /usr/lib/libstdc++*
cp -f /opt/gcc-4.8.2/lib64/libstdc++.so.6.0.18 /usr/lib/.
cp -f /opt/gcc-4.8.2/lib64/libstdc++.so.6 /usr/lib/.
注意其中的
當然也有一些簡化的方式,需要聯網升級,如下的這個說明
http://www.qtcn.org/bbs/apps.php?q=diary&a=detail&did=1456&uid=139371
此時就可以加上
注意:為了提高性能,我們只需要編譯需要的功能即可
成功後的安裝,就非常簡單了,類似如下的腳本過程
make install
#sudo cp -f my.cnf /etc/my.cnf
#sudo chmod 0444 /etc/my.cnf
sudo sh -c 'groupadd mysql'
sudo sh -c 'useradd -r -g mysql mysql'
sudo chown -R mysql /usr/local/mysql/data
sudo /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
#sudo cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
/usr/local/mysql/support-files/mysql.server start
login="/usr/local/mysql/bin/mysql -uroot -D mysql -e"
pass="/usr/local/mysql/bin/mysql -uroot -p123456 -D mysql -e"
${login} "update mysql.user set password=PASSWORD('123456') where user='root';"
${login} "flush privileges;"
詳細的資料和腳本參考 http://pan.baidu.com/s/1Cc7cr
由於新版的
#!/bin/bash
if [ $# = 1 ] ; then
#4.4
#
sudo update-alternatives --remove-all gcc
sudo update-alternatives --remove-all g++
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 40
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.4 40
#
sudo update-alternatives --config gcc
sudo update-alternatives --config g++
#
# rm -f /usr/lib/libstdc++*
# cp -f gcc4.4/libstdc++.so.6.0.13 /usr/lib/.
# ln -s /usr/lib/libstdc++.so.6.0.13 /usr/lib/libstdc++.so.6
else
#4.8
#gcc-4.8.2.tar.gz
if [ -d /opt/gcc-4.8.2 ]; then
echo "gcc 4.8.2 installed"
else
tar xzf gcc-4.8.2.tar.gz -C /opt
fi
#
sudo update-alternatives --remove-all gcc
sudo update-alternatives --remove-all g++
sudo update-alternatives --install /usr/bin/gcc gcc /opt/gcc-4.8.2/bin/gcc 40
sudo update-alternatives --install /usr/bin/g++ g++ /opt/gcc-4.8.2/bin/g++ 40
#
sudo update-alternatives --config gcc
sudo update-alternatives --config g++
#
# rm -f /usr/lib/libstdc++*
# cp -f /opt/gcc-4.8.2/lib64/libstdc++.so.6.0.18 /usr/lib/.
# cp -f /opt/gcc-4.8.2/lib64/libstdc++.so.6 /usr/lib/.
fi
#libstdc++.so.6
gcc -v
這裡有如上的相關資料和內容 http://pan.baidu.com/s/1Cc7cr
http://www.cnblogs.com/2018/p/3482263.html
http://www.cnblogs.com/2018/p/3464638.html
這兩篇已經介紹了clang的安裝和編譯c++庫的過程,下面會再講講mysql的clang編譯安裝過程