gtk2.x 静态编译时 需要注意的是 cairo
cairo 1.14.x 使用了 mutex , 用动态方式时 DllMain 中调用了 CAIRO_MUTEX_INITIALIZE ()
在静态编译时不能自动初始化 mutex , 所以 gtk 静态程序出现错误.
需要在 gtk_init() 中加载 CAIRO_MUTEX_INITIALIZE ();
在 gtk_quit_destroy() 中调用 CAIRO_MUTEX_FINALIZE ();
-------------------------------------------------------------------------------------------------------
build static libs
-------------------------------------------------------------------------------------------------------
export LIBFFI_CFLAGS=" -I/usr/local/lib/libffi-3.2.1/include "
export LIBFFI_LIBS=" -lffi "
export ZLIB_CFLAGS=-I/usr/local/include
export ZLIB_LIBS=-lz
export CFLAGS=" -I/usr/local/include -O2 -Wall -march=i686 -mms-bitfields -mthreads -static "
export CPPFLAGS=" -I/usr/local/include "
export LDFLAGS=" -L/usr/local/lib "
export LIBS=' -lpsapi -lws2_32 -lmswsock -lpthread -lffi -lole32 -lwinmm -lshlwapi -lintl -liconv -lgdiplus -luuid -lharfbuzz -lharfbuzz-icu -lexpat -lgdi32 -lmsimg32 -lz '
# -lsupc++
./configure --prefix=/usr/local
--enable-static
--disable-shared
--disable-gtk-doc
--enable-win32
--enable-win32-font
cairo (version 1.14.6 [release]) will be compiled with:
The following surface backends:
Image: yes (always builtin)
Recording: yes (always builtin)
Observer: yes (always builtin)
Mime: yes (always builtin)
Tee: no (disabled, use --enable-tee to enable)
XML: no (disabled, use --enable-xml to enable)
Skia: no (disabled, use --enable-skia to enable)
Xlib: no (requires X development libraries)
Xlib Xrender: no (requires --enable-xlib)
Qt: no (disabled, use --enable-qt to enable)
Quartz: no (requires CoreGraphics framework)
Quartz-image: no (disabled, use --enable-quartz-image to enable)
XCB: no (requires xcb >= 1.6 xcb-render >= 1.6 http://xcb.freedesktop.org)
Win32: yes
OS2: no (disabled, use --enable-os2 to enable)
CairoScript: yes
PostScript: yes
PDF: yes
SVG: yes
OpenGL: no (disabled, use --enable-gl to enable)
OpenGL ES 2.0: no (disabled, use --enable-glesv2 to enable)
BeOS: no (disabled, use --enable-beos to enable)
DirectFB: no (disabled, use --enable-directfb to enable)
OpenVG: no (disabled, use --enable-vg to enable)
DRM: no (disabled, use --enable-drm to enable)
Cogl: no (disabled, use --enable-cogl to enable)
The following font backends:
User: yes (always builtin)
FreeType: yes
Fontconfig: yes
Win32: yes
Quartz: no (requires CoreGraphics framework)
The following functions:
PNG functions: yes
GLX functions: no (not required by any backend)
WGL functions: no (not required by any backend)
EGL functions: no (not required by any backend)
X11-xcb functions: no (disabled, use --enable-xlib-xcb to enable)
XCB-shm functions: no (requires --enable-xcb)
The following features and utilities:
cairo-trace: no (requires dynamic linker and zlib and real pthreads)
cairo-script-interpreter: yes
And the following internal features:
pthread: yes
gtk-doc: no
gcov support: no
symbol-lookup: no (requires bfd)
test surfaces: no (disabled, use --enable-test-surfaces to enable)
ps testing: no (requires libspectre)
pdf testing: no (requires poppler-glib >= 0.17.4)
svg testing: no (requires librsvg-2.0 >= 2.35.0)
win32 printing testing: no (requires ghostscript)
----------------------------------------------------------------------------------
src/win32/cairo-win32-system.c
----------------------------------------------------------------------------------
/*
BOOL WINAPI
DllMain (HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpvReserved);
BOOL WINAPI
DllMain (HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpvReserved)
{
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
CAIRO_MUTEX_INITIALIZE ();
break;
case DLL_PROCESS_DETACH:
CAIRO_MUTEX_FINALIZE ();
break;
}
return TRUE;
} */
----------------------------------------------------------------------------------
__declspec(dllexport) fix to --> __attribute__((visibility ("default")))
define xxx __declspec(dllimport) fix to --> define xxx extern
__attribute__((visibility ("hidden"))) fix to --> __attribute__((visibility ("default")))
delete all DllMain function
srccairoint.h(54):#define cairo_public __declspec(dllexport)
#define cairo_public __declspec(dllexport) -> __attribute__((visibility ("default")))
srccairo.h(55):# define cairo_public __declspec(dllimport)
#define cairo_public __declspec(dllimport) -> extern
srccairo-compiler-private.h(120):#define cairo_private_no_warn __attribute__((__visibility__("hidden")))
#define cairo_private_no_warn __attribute__((__visibility__("hidden"))) -> ("default")
utilcairo-scriptcairo-script-private.h(165):#define csi_private_no_warn __attribute__((__visibility__("hidden")))
#define csi_private_no_warn __attribute__((__visibility__("hidden"))) -> ("default")
----------------------------------------------------------------------------------
src/cairo.h
----------------------------------------------------------------------------------
cairo_public void cairo_mutex_init();
cairo_public void cairo_mutex_finalize();
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
src/cairo.c
----------------------------------------------------------------------------------
void cairo_mutex_init()
{
CAIRO_MUTEX_INITIALIZE ();
}
void cairo_mutex_finalize()
{
CAIRO_MUTEX_FINALIZE ();
}
----------------------------------------------------------------------------------
链接:http://pan.baidu.com/s/1hrXKrBY 密码:fxh0
_cairo-1.14.6-staticLib.7z