设为首页 加入收藏

TOP

基于Windows平台编译libmemcached的步骤 (一)
2014-11-23 23:36:37 来源: 作者: 【 】 浏览:41
Tags:基于 Windows 平台 编译 libmemcached 步骤

1. 下载MinGW32到本地,以便能够使用gcc编译器以及和linux相关的一些库文件。

2. 由于libmemcached的测试程序需要依赖memcached.exe本身,如果需要将memcached在win32下编译,需要修改部分和socket相关的code,而又考虑到仅仅是测试用例需要,因此决定通过修改configure(由autoconfig用于生成makefile的配置信息检查的shell文件)文件,以使libmemcached的编译不在依赖memcached。

3. 为了完成第二步,需要手工修改configure文件,将如下shell代码注释掉,以便在执行./configure的时候不再将memcached.exe作为一个必须的配置检查条件。注: 在该文件中搜索--with-memcached即可找到以下code

# Check whether --with-memcached was given.

#if test "${with_memcached+set}" = set; then :

# withval=$with_memcached; ac_cv_with_memcached="$withval"

#else

# ac_cv_with_memcached=memcached

#fi

# just ignore the user if --without-memcached is passed.. it is

# only used by make test

# if test "x$withval" = "xno"; then :

#

# ac_cv_with_memcached=memcached

# MEMC_BINARY=memcached

#else

#

# if test -f "$withval"; then :

#

# ac_cv_with_memcached=$withval

# MEMC_BINARY=$withval

#

#else

#

# Extract the first word of "$ac_cv_with_memcached", so it can be a program name with args.

#set dummy $ac_cv_with_memcached; ac_word=$2

#{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5

#$as_echo_n "checking for $ac_word... " >&6; }

#if test "${ac_cv_path_MEMC_BINARY+set}" = set; then :

# $as_echo_n "(cached) " >&6

#else

# case $MEMC_BINARY in

# [\\/]* | :[\\/]*)

# ac_cv_path_MEMC_BINARY="$MEMC_BINARY" # Let the user override the test with a path.

# ;;

# *)

# as_save_IFS=$IFS; IFS=$PATH_SEPARATOR

#for as_dir in $PATH

#do

# IFS=$as_save_IFS

# test -z "$as_dir" && as_dir=.

# for ac_exec_ext in '' $ac_executable_extensions; do

# if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then

# ac_cv_path_MEMC_BINARY="$as_dir/$ac_word$ac_exec_ext"

# $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5

# break 2

# fi

#done

# done

#IFS=$as_save_IFS

# test -z "$ac_cv_path_MEMC_BINARY" && ac_cv_path_MEMC_BINARY=""no""

# ;;

#esac

#fi

#MEMC_BINARY=$ac_cv_path_MEMC_BINARY

#if test -n "$MEMC_BINARY"; then

# { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MEMC_BINARY" >&5

#$as_echo "$MEMC_BINARY" >&6; }

#else

# { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5

#$as_echo "no" >&6; }

#fi

#

#

# if test "x$MEMC_BINARY" = "xno"; then :

# as_fn_error $ "\"could not find memcached binary\"" "$LINENO" 5

#fi

#

#fi

#

#fi

#cat >>confdefs.h <<_ACEOF

#define MEMCACHED_BINARY "$MEMC_BINARY"

#_ACEOF

4. 从以上代码中可以发现MEMCACHED_BINARY宏是需要在程序中用到的,此时需要手工将用到该宏的地方进行修改,如下: (请参见libtest/server.c,同时搜索字符串MEMCACHED_BINARY)

if (x == 0)

{

// 原有代码

// snprintf(buffer, sizeof(buffer), "%s -d -P %s -t 1 -p %u -U %u -m 128",

// MEMCACHED_BINARY, construct->pid_file[x], construct->port[x], construct->port[x]);

// 修改为

snprintf(buffer, sizeof(buffer), "-d -P %s -t 1 -p %u -U %u -m 128",

construct->pid_file[x], construct->port[x], construct->port[x]);

}

else

{

// 原有代码

// snprintf(buffer, sizeof(buffer), "%s -d -P %s -t 1 -p %u -U %u",

// MEMCACHED_BINARY, construct->pid_file[x], construct->port[x], construct->port[x]);

// 修改为

snprintf(buffer, sizeof(buff

首页 上一页 1 2 3 下一页 尾页 1/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇一个字符串找查的例子 下一篇C语言移位

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: