cmake編譯問題解決

白及88發表於2016-03-18

2 安裝cmake軟體包
yum install cmake

3 create account of mysql
groupadd mysql           
useradd -g mysql mysql           
autoreconf –force –install
libtoolize –automake –force
automake –force –add-missing

4  complie the sources
mkdir -p /data/mbdata
tar -xvf mysql-5.6.13.tar.gz 

5 cmake

 time cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql56 -DMYSQL_DATADIR=/data56 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR==/data56/mysql.sock -DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci

[root@472322 mysql-5.6.13]# time cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql56 -DMYSQL_DATADIR=/data56 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR==/data56/mysql.sock -DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
— Running cmake version 2.6.4
CMake Error: CMake was unable to find a build program corresponding to “Unix Makefiles”.  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER
CMake Error: Could not find cmake module file:/root/mysql-5.6.13/CMakeFiles/CMakeCCompiler.cmake
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER
CMake Error: Could not find cmake module file:/root/mysql-5.6.13/CMakeFiles/CMakeCXXCompiler.cmake
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
— Configuring incomplete, errors occurred!

real    0m0.017s
user    0m0.006s
sys     0m0.005s

6 上一步cmake報錯了,google得知需要重新yum make下

yum install make
ok

再繼續去cmake
[root@472322 mysql-5.6.13]# time cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql56 -DMYSQL_DATADIR=/data56 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR==/data56/mysql.sock -DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
— Running cmake version 2.6.4
— The C compiler identification is unknown
— The CXX compiler identification is unknown
CMake Error: your C compiler: “CMAKE_C_COMPILER-NOTFOUND” was not found.   Please set CMAKE_C_COMPILER to a valid compiler path or name.
CMake Error: your CXX compiler: “CMAKE_CXX_COMPILER-NOTFOUND” was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
— Searching 16 bit integer
CMake Error at /usr/share/cmake/Modules/TestBigEndian.cmake:31 (MESSAGE):
  no suitable type found
Call Stack (most recent call first):
  configure.cmake:621 (TEST_BIG_ENDIAN)
  CMakeLists.txt:314 (INCLUDE)

這個錯誤很詭異,google上面有很多,但是每種情況都不同,我只好一個個去try了

— Configuring incomplete, errors occurred!

報錯如下: CMake Error: your C compiler: “CMAKE_C_COMPILER-NOTFOUND” was not found.
 沒有安裝 gcc 和 gcc-c++,執行cmake報如上錯誤:
 第一次嘗試,執行
yum install -y gcc
yum install -y gcc-c++


7  繼續cmake

time cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql56 -DMYSQL_DATADIR=/data56 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR==/data56/mysql.sock -DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci


— Searching 16 bit integer
CMake Error at /usr/share/cmake/Modules/TestBigEndian.cmake:31 (MESSAGE):
  no suitable type found
Call Stack (most recent call first):
  configure.cmake:621 (TEST_BIG_ENDIAN)
  CMakeLists.txt:314 (INCLUDE)
— Configuring incomplete, errors occurred!

第二次嘗試,有人說需要安裝至少5種包
[root@472322 mysql-5.6.13]# 
yum install gcc gcc-c++
    yum install -y ncurses-devel.x86_64
    yum install -y cmake.x86_64
    yum install -y libaio.x86_64
    yum install -y bison.x86_64
yum install -y gcc-c++.x86_64

然後再cmake,還是報原來的錯誤

最後決定用土辦法了,刪除所有的已經安裝過的,重新再來做一遍吧。

[解決辦法]:刪除原來的mysql-5.6.13目錄,重新解壓縮tar.gz包

rm -rf /root/mysql-5.6.13
cd /root/
tar -xvf mysql-5.6.13.tar.gz 
cd /root/mysql-5.6.13
time cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql56 -DMYSQL_DATADIR=/data56 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR==/data56/mysql.sock -DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci

OK,成功了,對linux底層不太熟悉,難道是因為前面沒有事先安裝好各種包而cmake出來錯誤的東西導致後面繼續cmake就一直報錯嗎? 是否是需要準備好各種lib包然後才能yum install cmake呢?然後再安裝mysql才能不報錯呢?

8 build the db directy
time make 
time make install

9 init db
ll /usr/local/mysql56/
cd /usr/local/mysql56/
chown -R mysql .
chgrp -R mysql .
cp support-files/my-default.cnf /etc/my56.cnf
scripts/mysql_install_db  –user=mysql –basedir=/usr/local/mysql56 –datadir=/data56 –defaults-file=/etc/my56.cnf
[root@472322 mysql56]# scripts/mysql_install_db  –user=mysql –basedir=/usr/local/mysql56 –datadir=/data56 –defaults-file=/etc/my56.cnf

  /usr/local/mysql56/bin/mysqladmin -u root password `new-password`
  /usr/local/mysql56/bin/mysqladmin -u root -h 472322.ea.com password `new-password`

Alternatively you can ru
–defaults-file argument to mysqld_safe when starting the server

感到資訊有warning,那就重新再執行一遍,原來在做5.6.10安裝測試的時候,init db不管第一次執行失敗或者成功,都可以再執行第二遍的。


相關文章