一、安装环境
操作系统:window8.1
cygwin:x86_64
mysql:Generic Linux (Architecture Independent) 5.6.17
二、cmake编译命令
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=0 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
三、编译时问题
错误1
In file included from /cygdrive/d/openSource/mysql/mysql-5.6.17.tar/mysql-5.6.17/cmd-line-utils/libedit/readline.c:54:0:
/cygdrive/d/openSource/mysql/mysql-5.6.17.tar/mysql-5.6.17/cmd-line-utils/libedit/editline/readline.h:79:29: 致命错误:sys/ttydefaults.h:No such file or directory
#include <sys/ttydefaults.h>
解决方法
在readline.h中
#if !defined(__sun) && !defined(__hpux) && !defined(_AIX) && !defined(__QNXNTO__) && !defined(__USLC__)
修改为
#if !defined(__sun) && !defined(__hpux) && !defined(_AIX) && !defined(__QNXNTO__) && !defined(__USLC__) && !defined(__CYGWIN__)
参考
http://blog.csdn.net/zhukanjie/article/details/6129389
http://www.cygwin.com/ml/cygwin/2010-01/msg01124.html
错误2
/cygdrive/d/openSource/mysql/mysql-5.6.17.tar/mysql-5.6.17/cmd-line-utils/libedit/vi.c:921:19: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘char’
__weakref_visible char *my_get_alias_text(const char *)
^
/cygdrive/d/openSource/mysql/mysql-5.6.17.tar/mysql-5.6.17/cmd-line-utils/libedit/vi.c:922:36: 错误:宏“__weak_reference”需要 2 个参数,但只给出了 1 个
__weak_reference(get_alias_text);
^
/cygdrive/d/openSource/mysql/mysql-5.6.17.tar/mysql-5.6.17/cmd-line-utils/libedit/vi.c: 在函数‘vi_alias’中:
/cygdrive/d/openSource/mysql/mysql-5.6.17.tar/mysql-5.6.17/cmd-line-utils/libedit/vi.c:933:6: 错误:‘my_get_alias_text’未声明(在此函数内第一次使用)
解决方法
文件:vi.c
在代码“#if defined(__weak_reference) && !defined(__FreeBSD__)” 前增加
#ifdef __CYGWIN__
#undef __weak_reference
#endif
错误3
/cygdrive/e/opensource/mysql/mysql-5.6.17.tar/mysql-5.6.17/strings/dtoa.c:55:14: 错误:与‘dtoa’类型冲突
static char *dtoa(double, int, int, int *, int *, char **, char *, size_t);
^
In file included from /usr/include/sys/types.h:20:0,
from /usr/include/pthread.h:14,
from /cygdrive/e/opensource/mysql/mysql-5.6.17.tar/mysql-5.6.17/include/my_global.h:266,
from /cygdrive/e/opensource/mysql/mysql-5.6.17.tar/mysql-5.6.17/include/my_base.h:24,
from /cygdrive/e/opensource/mysql/mysql-5.6.17.tar/mysql-5.6.17/strings/dtoa.c:39:
/usr/include/stdlib.h:169:8: 附注:‘dtoa’的上一个声明在此
char * _EXFUN(dtoa,(double, int, int, int *, int*, char**));
^
strings/CMakeFiles/strings.dir/build.make:586: recipe for target 'strings/CMakeFiles/strings.dir/dtoa.c.o' failed
解决方法
dtoa.c中将dtoa替换为_dtoa
错误4
In file included from /cygdrive/e/opensource/mysql/mysql-5.6.17.tar/mysql-5.6.17/storage/innobase/handler/ha_innodb.cc:47:0:
/cygdrive/e/opensource/mysql/mysql-5.6.17.tar/mysql-5.6.17/storage/innobase/include/fts0priv.ic: 在函数‘ulint fts_read_object_id(ib_id_t*, const char*)’中:
/cygdrive/e/opensource/mysql/mysql-5.6.17.tar/mysql-5.6.17/storage/innobase/include/univ.i:453:26: 错误:expected ‘)’ before ‘PRIx64’
# define UINT64PFx "%016"PRIx64
^
/cygdrive/e/opensource/mysql/mysql-5.6.17.tar/mysql-5.6.17/storage/innobase/include/fts0priv.ic:69:21: 附注:in expansion of macro ‘UINT64PFx’
return(sscanf(str, UINT64PFx, id) == 1);
^
解决方法
修改文件univ.i
# define UINT32PF "%"PRIu32
# define INT64PF "%"PRId64
# define UINT64PF "%"PRIu64
# define UINT64PFx "%016"PRIx64
# define DBUG_LSN_PF UINT64PF
修改为
#if defined (__CYGWIN__)
# define UINT32PF "%""u"
# define INT64PF "%""l""d"
# define UINT64PF "%""l""u"
# define UINT64PFx "%016d""l""x"
# define DBUG_LSN_PF UINT64PF
#else
# define UINT32PF "%"PRIu32
# define INT64PF "%"PRId64
# define UINT64PF "%"PRIu64
# define UINT64PFx "%016"PRIx64
# define DBUG_LSN_PF UINT64PF
#endif /*__INSIDE_CYGWIN__*/
原因
在cygwin环境下,g++使用的inttypes.h在目录/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/include中
该文件中没有UINT32PF的定义,所以会导致编译错误
安装问题
运行 make install会碰到如下问题
-- Installing: /usr/local/mysql/./README
CMake Error at cmake_install.cmake:42 (FILE):
file INSTALL cannot set permissions on "/usr/local/mysql/./README"
解决方法
chmod 777 -R *
修改所有的文件属性
原因
目录下的文件不具备读写等属性
参考
1、用于在编译中进行调试的gcc/g++命令
http://www.lingcc.com/2011/06/27/11679/