介紹本頁將介紹常用編譯工具的一些配置選項和這些配置選項在cmake中又是如何進行配置的,然後介紹如何使用cmake工具來構建編譯mysql。
命令呼叫語法
下表列出了常用編譯工具的呼叫語法和等效的cmake命令。「.」表示你當前的工作目錄路徑,請根據你所在的目錄,適當的替換掉路徑「.」。
configure命令
cmake命令
./configure
cmake .
./configure --help
cmake . -lh or ccmake .
在重新配置或重新構建之前,需要先清除舊的物件檔案和快取資訊,方法如下:
autotools:
view plain
copy
make clean
rm config.cache
cmake (unix/linux):
view plain
copy
make clean
rm cmakecache.txt
cmake (windows):
view plain
copy
devenv mysql.sln /clean
del cmakecache.txt
安裝引數選項
在下表中,「cmake_install_prefix」的值表示的是安裝根目錄,其他引數值的路徑都是相對於根目錄的,當然你也可以直接使用絕對路徑,具體如下:
引數值說明
配置選項
cmak選項
安裝根目錄
--prefix=/usr
-dcmake_install_prefix=/usr
mysqld目錄
--libexecdir=/usr/sbin
-dinstall_sbindir=sbin
資料儲存目錄
--localstatedir=/var/lib/mysql
-dmysql_datadir=/var/lib/mysql
配置檔案(my.cnf)目錄
--sysconfdir=/etc/mysql
-dsysconfdir=/etc/mysql
外掛程式目錄
--with-plugindir=/usr/lib64/mysql/plugin
-dinstall_plugindir=lib64/mysql/plugin
手冊檔案目錄
--mandir=/usr/share/man
-dinstall_mandir=share/man
共享資料目錄
--sharedstatedir=/usr/share/mysql
-dinstall_sharedir=share
library庫目錄
--libdir=/usr/lib64/mysql
-dinstall_libdir=lib64/mysql
header安裝目錄
--includedir=/usr/include/mysql
-dinstall_includedir=include/mysql
資訊文件目錄
--infodir=/usr/share/info
-dinstall_infodir=share/info
儲存引擎選項
儲存引擎是以外掛程式的形式存在的,所以,該選項可以控制外掛程式的構建,比如指定使用某個特定的引擎。
--with-plugins配置選項接受兩種形式的引數值,它沒有對應的cmake配置引數:
① 以逗號(,)分隔的引擎名稱列表;
② a "group name" value that is shorthand for a set of engines
在cmake中,引擎被作為單個的選項來進行控制。假設有以下配置選項:
view plain
copy
--with-plugins
=csv
,myisam,myisammrg,heap,innobase,archive,blackhole
上面的引數指定mysql資料庫可以支援哪些資料庫引擎,將上述編譯選項轉換成cmake編譯選項時,下面的幾個引擎名字可以被省略,因為編譯時,預設就支援:
view plain
copy
csv myisam myisammrg heap
然後使用下面的編譯引數,以啟用innodb、archive和blackhole引擎支援:
view plain
copy
-dwith_innobase_storage_engine=1
-dwith_archive_storage_engine=1
-dwith_blackhole_storage_engine=1
當然也可以使用「on」來替代數字1,它們是等效的。
如果你想除去對某種引擎的支援,則在cmake編譯選項中使用-dwithout__storage_engine,例如:
view plain
copy
-dwithout_example_storage_engine=1
-dwithout_federated_storage_engine=1
-dwithout_partition_storage_engine=1
庫檔案載入選項
該選項指明mysql使用庫的情況:
引數值說明
配置選項
cmak選項
readline庫
--with-readline
-dwith_readline=1
ssl庫
--with-ssl=/usr
-dwith_ssl=system
zlib庫
--with-zlib-dir=/usr
-dwith_zlib=system
libwrap庫
--without-libwrap
-dwith_libwrap=0
其他選項
cmake編譯選項支援大部分之前版本的mysql編譯選項,新老編譯選項的差別在於:之前的是小寫,現在全部變成了大寫,之前採用雙橫線,現在使用單橫線,之前使用的破折號,現在取而代之的是使用下劃線,例如:
view plain
copy
--with-debug
=>
with_debug=1
--with-embedded-server
=>
with_embedded_server
下面是編譯mysql的新老引數對照表:
引數值說明
配置選項
cmak選項
tcp/ip埠
--with-tcp-port-=3306
-dmysql_tcp_port=3306
unix socket檔案
--with-unix-socket-path=/tmp/mysqld.sock
-dmysql_unix_addr=/tmp/mysqld.sock
啟用載入本地資料
--enable-local-infile
-denabled_local_infile=1
擴充套件字元支援
--with-extra-charsets=all(預設:all)
-dextra_charsets=all(預設:all)
預設字符集
--with-charset=utf8
-ddefault_charset=utf8
預設字元校對
--with-collation=utf8_general_ci
-ddefault_collation=utf8_general_ci
build the server
--with-server
無嵌入式伺服器
--with-embedded-server
-dwith_embedded_server=1
libmysqld許可權控制
--with-embedded-privilege-control
無安裝文件
--without-docs
無big tables支援
--with-big-tables, --without-big-tables
無mysqld執行使用者
--with-mysqld-user=mysql
-dmysql_user=mysql
除錯模式
--without-debug(預設禁用)
-dwith_debug=0(預設禁用)
gis支援
--with-geometry
無社群功能
--enable-community-features
無profiling
--disable-profiling(預設啟用)
-denable_profiling=0(預設啟用)
pstack
--without-pstack
無(新版移除該功能)
彙編字串函式
--enable-assembler
無構建型別
--build=x86_64-pc-linux-gnu
沒有等效引數
交叉編譯主機
--host=x86_64-pc-linux-gnu
沒有等效引數
客戶端標誌
--with-client-ldflags=-lstdc++
無線程安全標誌
--enable-thread-safe-client
無注釋儲存型別
--with-comment='string'
-dwith_comment='string'
shared/static binaries
--enable-shared --enable-static
無記憶體使用控制
--with-low-memory
無
Cache control引數說明
header中的cache control引數說明 php編碼 網頁的快取是由http訊息頭中的 cache control 來控制的,常見的取值有private no cache max age must revalidate等,預設為private。其作用根據不同的重新瀏覽方式分為以下幾種情況 ...
nmap引數說明
目標規範 可以通過主機名,ip位址,網路等 例 scanme.nmap.org,dream4.org 24,192.168.0.1 10.0.0 255.1 254 il 從指定檔案獲取主機或網路 ir 隨機選擇主機,0 不限制掃瞄主機數 exclude 排除指定主機或網路 excludefile ...
toString引數說明
格式化數值 有時,我們可能需要將數值以一定的格式來呈現,就需要對數值進行格式化。我們使用格式字串指定格式。格式字串採用以下形式 axx,其中 a 為格式說明符,指定格式化型別,xx 為精度說明符,控制格式化輸出的有效位數或小數字數。格式說明符 說明 示例 輸出 c 貨幣 2.5.tostring c...