天天看点

cmake编译问题解决

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_c_compiler

cmake error: could not find cmake module file:/root/mysql-5.6.13/cmakefiles/cmakeccompiler.cmake

cmake_cxx_compiler_env_var

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

-- 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了

报错如下: 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

第二次尝试,有人说需要安装至少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/

cd /root/mysql-5.6.13

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不管第一次执行失败或者成功,都可以再执行第二遍的。

继续阅读