glib windows build

1、首先下载glib的依赖库 source codes。
gettext ( libintl ) 库:
libiconv 库:
libffi 库:
pcre 库:
zlib 库:
2、下载完成后,采用 vs2013 进行对各个库进行编译的。
build libintl 库 :修改头文件 libgnuintl.h ,包括两部分:
一:修改 C++ 部分接口定义,如下:
#ifdef _INTL_REDIRECT_INLINE
extern char *libintl_gettext (const char *__msgid)
_INTL_MAY_RETURN_STRING_ARG (1);
extern char *gettext(const char *__mgsid);
二:修改 C 部分接口定义,如下:
#else
DLL_EXPORTED char *gettext (const char *__msgid)
_INTL_MAY_RETURN_STRING_ARG (1);
#endif
其他接口也类似。
 
build libiconv 库:不需要修改,可直接编译。
 
build libffi 库:不需要修改,可直接编译。
 
build pcre 库:
(1)、将 config.h.in 文件重命名为config.h,并将文件中 #define HAVE_STRERROR 0和#defineHAVE_MEMMOVE 0 改成 #define HAVE_STRERROR 1 和 #define HAVE_MEMMOVE 1。
(2)、新建一个项目,添加源文件 dftables.c,编译生成 dftables.exe 文件,然后在cmd命令行中执行如下命令:dftables.exe pcre_chartables.c。
(3)、新建动态库项目 pcre,添加源文件:
pcre_chartables.c
pcre_compile.c
pcre_config.c
pcre_dfa_exec.c
pcre_exec.c
pcre_fullinfo.c
pcre_get.c
pcre_globals.c
pcre_info.c
pcre_maketables.c
pcre_newline.c
pcre_ord2utf8.c
pcre_printint.src
pcre_refcount.c
pcre_study.c
pcre_tables.c
pcre_try_flipped.c
pcre_ucp_searchfuncs.c
pcre_valid_utf8.c
pcre_version.c
pcre_xclass.c
添加头文件:
config.h
pcre.h
pcre_internal.h
pcre_scanner.h
pcrecpp.h
pcreposix.h
ucp.h
ucpinternal.h
(4)、打开 pcre.h 头文件,添加如下代码:
#define PCRE_MAJOR 7
#define PCRE_MINOR 0
#define PCRE_PRERELEASE
#define PCRE_DATE 18-Dec-2006
 
/* When building a DLL, we must export some functions. Note that because
the functions are only defined for binary backward compatibility, we
don't need to use __declspec(dllimport) in any case. */
#if HAVE_VISIBILITY && BUILDING_DLL
# define DLL_EXPORTED __attribute__((__visibility__("default")))
#elif defined _MSC_VER && BUILDING_DLL
# define DLL_EXPORTED __declspec(dllexport)
#else
# define DLL_EXPORTED
#endif
 
/* Win32 uses DLL by default; it needs special stuff for exported functions
when building PCRE. */
 
#ifdef _WIN32
# ifdef PCRE_DEFINITION
# ifdef DLL_EXPORTED
# define PCRE_DATA_SCOPE __declspec(dllexport)
# endif
# else
# ifndef PCRE_STATIC
# define PCRE_DATA_SCOPE extern __declspec(dllimport)
# endif
# endif
#endif
(5)、编译 pcre 项目生成 pcre.dll 和 pcre.lib 文件。
(6)、新建静态库项目 posixpcre,添加源代码 pcreposix.c ,编译项目生成 posixpcre.lib。
(7)、编译 pcre 库完成。
 
build zlib 库:
打开项目文件 contril\vstudio\vc10\zlibvc.sln 直接编译。
 
3、下载 glib 的 source codes,然后打开项目文件 build\win32\vs12\glib.sln,为项目配置头文件目录和库目录,最后进行编译。
 
附上源码路径:https://github.com/panliang505/glib.git
posted @ 2017-03-28 21:28  潘三爷  阅读(1454)  评论(0编辑  收藏  举报