编译安装MySQL报错CMake Error: your C compiler

编译安装MySQL的时候,报如下错误:

-- Running cmake version 2.8.12.2
-- Could NOT find Git (missing:  GIT_EXECUTABLE) 
-- Configuring with MAX_INDEXES = 64U
-- 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.
-- CMAKE_GENERATOR: Unix Makefiles
CMake Error at cmake/os/Linux.cmake:50 (MESSAGE):
    Unsupported compiler!
Call Stack (most recent call first):
    CMakeLists.txt:198 (INCLUDE)

请问这个如何解决?

已邀请:

空心菜 - 心向阳光,茁壮成长

赞同来自: koyo

报错如下:

[ 19%] Building CXX object storage/innobase/CMakeFiles/innobase.dir/handler/handler0alter.cc.o
/data/make/mysql-5.7.33/storage/innobase/handler/handler0alter.cc: In member function ‘virtual bool ha_innobase::commit_inplace_alter_table(TABLE*, Alter_inplace_info*, bool)’:
/data/make/mysql-5.7.33/storage/innobase/handler/handler0alter.cc:9015:1: error: could not split insn
}
^
(insn 7305 19453 19455 (parallel [
(set (reg:DI 0 x0 [orig:834 D.184642 ] [834])
(plus:DI (mem/v:DI (reg/f:DI 28 x28 [2520]) [-1 S8 A64])
(const_int 536870912 [0x20000000])))
(set (mem/v:DI (reg/f:DI 28 x28 [2520]) [-1 S8 A64])
(unspec_volatile:DI [
(mem/v:DI (reg/f:DI 28 x28 [2520]) [-1 S8 A64])
(const_int 536870912 [0x20000000])
(const_int 5 [0x5])
] UNSPECV_ATOMIC_OP))
(clobber (reg:CC 66 cc))
(clobber (reg:SI 6 x6))
]) /data/make/mysql-5.7.33/storage/innobase/include/sync0rw.ic:317 1856 {atomic_add_fetchdi}
(expr_list:REG_UNUSED (reg:CC 66 cc)
(expr_list:REG_UNUSED (reg:SI 6 x6)
(nil))))
/data/make/mysql-5.7.33/storage/innobase/handler/handler0alter.cc:9015:1: internal compiler error: in final_scan_insn, at final.c:2897
Please submit a full bug report,
with preprocessed source if appropriate.
See for instructions.
Preprocessed source stored into /tmp/ccnEOuYV.out file, please attach this to your bugreport.
make[2]: *** [storage/innobase/CMakeFiles/innobase.dir/handler/handler0alter.cc.o] Error 1
make[1]: *** [storage/innobase/CMakeFiles/innobase.dir/all] Error 2
make: *** [all] Error 2

按日志这个貌似是mysql在aarch64架构下的bug,https://bugs.mysql.com/bug.php?id=97547
mariadb在aarch64好像也是有bug的,可以按上面bug里的提示按 https://www.vpser.net/manage/centos-6-upgrade-gcc.html升级gcc 7后再试试看。

原因:当时使用的gcc版本(gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC))较低


解决:

yum install centos-release-scl
yum install devtoolset-7-gcc devtoolset-7-gcc-c++ -y
export CC=/opt/rh/devtoolset-7/root/bin/gcc
export CXX=/opt/rh/devtoolset-7/root/bin/g++
export CPP=/opt/rh/devtoolset-7/root/usr/bin/cpp

然后再cmake


空心菜 - 心向阳光,茁壮成长

这个是因为cmake依赖gcc,你没有安装gcc的包,如下安装即可:

yum -y install gcc gcc-c++

koyo - 网站管理 致力做全栈工程师 爱ui 爱前端

补充编译,修改版本报错问题,修改版本操作如下:

vim VERSION 
cat VERSION
MYSQL_VERSION_MAJOR=5
MYSQL_VERSION_MINOR=7
MYSQL_VERSION_PATCH=100
MYSQL_VERSION_EXTRA=
# MYSQL_VERSION_PATCH=100 33改成100

报错信息:

[ 66%] Building CXX object storage/innobase/CMakeFiles/innobase_embedded.dir/sync/sync0debug.cc.o
In file included from /data/make/mysql-5.7.33/libmysqld/lib_sql.cc:30:0:
/data/make/mysql-5.7.33/libmysqld/../sql/mysqld.cc:355:2: error: #error "show_compatibility_56 is to be removed in MySQL 5.8"
#error "show_compatibility_56 is to be removed in MySQL 5.8"
^
[ 66%] Building CXX object storage/innobase/CMakeFiles/innobase_embedded.dir/sync/sync0sync.cc.o
[ 66%] Building CXX object storage/innobase/CMakeFiles/innobase_embedded.dir/trx/trx0i_s.cc.o
make[2]: *** [libmysqld/CMakeFiles/sql_embedded.dir/lib_sql.cc.o] Error 1
make[1]: *** [libmysqld/CMakeFiles/sql_embedded.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

解决:

# 修改源码
vim sql/mysqld.cc # 修改354 ~ 362行

由:

#if MYSQL_VERSION_ID >= 50800
#error "show_compatibility_56 is to be removed in MySQL 5.8"
#else
/*
Default value TRUE for the EMBEDDED_LIBRARY,
default value from Sys_show_compatibility_56 otherwise.
*/
my_bool show_compatibility_56= TRUE;
#endif /* MYSQL_VERSION_ID >= 50800 */

改为:

/*
#if MYSQL_VERSION_ID >= 50800
#error "show_compatibility_56 is to be removed in MySQL 5.8"
#else
*/
/*
Default value TRUE for the EMBEDDED_LIBRARY,
default value from Sys_show_compatibility_56 otherwise.
*/
my_bool show_compatibility_56= TRUE;
//#endif /* MYSQL_VERSION_ID >= 50800 */

koyo - 网站管理 致力做全栈工程师 爱ui 爱前端

补充编译过程中遇到的其他错误。

错误1: SHA512_DIGEST_LENGTH - not found

-- Looking for unistd.h - found
-- OPENSSL_INCLUDE_DIR = OPENSSL_INCLUDE_DIR-NOTFOUND
-- OPENSSL_LIBRARY = OPENSSL_LIBRARY-NOTFOUND
-- CRYPTO_LIBRARY = CRYPTO_LIBRARY-NOTFOUND
-- OPENSSL_MAJOR_VERSION =
-- OPENSSL_MINOR_VERSION =
-- OPENSSL_FIX_VERSION =
-- Looking for SHA512_DIGEST_LENGTH
-- Looking for SHA512_DIGEST_LENGTH - not found
--

Cannot find appropriate system libraries for WITH_SSL=system.
Make sure you have specified a supported SSL version.
Valid options are :
system (use the OS openssl library),

解决:

yum -y install openssl-devel


错误2:Could NOT find Curses

-- Check size of wint_t - done
-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline.cmake:71 (MESSAGE):
Curses library not found. Please install appropriate package,
remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
Call Stack (most recent call first):
cmake/readline.cmake:102 (FIND_CURSES)
cmake/readline.cmake:195 (MYSQL_USE_BUNDLED_EDITLINE)
CMakeLists.txt:582 (MYSQL_CHECK_EDITLINE)

-- Configuring incomplete, errors occurred!
See also "/data/make/mysql-5.7.33/CMakeFiles/CMakeOutput.log".
See also "/data/make/mysql-5.7.33/CMakeFiles/CMakeError.log".

解决:

yum -y install ncurses-devel


错误3:Package ‘libtirpc’, required by ‘virtual:world’, not found

-- Checking for module 'libtirpc'
-- Package 'libtirpc', required by 'virtual:world', not found

CMake Error at cmake/rpc.cmake:65 (MESSAGE):
Could not find rpc/rpc.h in /usr/include or /usr/include/tirpc

Call Stack (most recent call first):
plugin/group_replication/libmysqlgcs/configure.cmake:57 (MYSQL_CHECK_RPC)
plugin/group_replication/libmysqlgcs/CMakeLists.txt:28 (INCLUDE)

解决:

yum install -y libtirpc-devel

空心菜 - 心向阳光,茁壮成长

报错补充如下:

[ 58%] Building CXX object sql/CMakeFiles/sql.dir/mysqld.cc.o
/data/make/mysql-5.7.33/sql/mysqld.cc: In function ‘passwd* check_user(const char*)’:
/data/make/mysql-5.7.33/sql/mysqld.cc:1564:12: error: ‘prctl’ was not declared in this scope
(void) prctl(PR_SET_DUMPABLE, 1);
^~~~~
make[2]: *** [sql/CMakeFiles/sql.dir/mysqld.cc.o] Error 1
make[1]: *** [sql/CMakeFiles/sql.dir/all] Error 2
make: *** [all] Error 2

解决:

cp /usr/include/sys/prctl.h /data/make/mysql-5.7.33/include/

vim /data/make/mysql-5.7.33/sql/mysqld.cc
#在24行后添加 #include "prctl.h"

/uploads/answer/20210417/c75c88e56c53750bafb65a532e43c775.png

要回复问题请先登录注册