glib-2.49.4 MSYS 静态库 编译 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 " \export CPPFLAGS=" -I/usr/local/include " \export LDFLAGS=" -L/usr/local/lib " \export LIBS=' -lpsapi -lws2_32 -lmswsock -lpthread './configure \--prefix=/usr/local \--enable-static \--disable-shared \--disable-debug \--disable-gtk-doc \--with-pcre=internal \--enable-silent-rules__declspec(dllexport) fix to --> __attribute__((visibility ("default")))__stdcall _export fix to --> __attribute__((visibility ("default")))define PNG_IMPEXP __declspec(dllimport) fix to --> define PNG_IMPEXP__attribute__((visibility ("hidden"))) fix to --> __attribute__((visibility ("default")))delete all DllMain functionconfig.h-------------------------------------------/* #define _GLIB_EXTERN __attribute__((visibility("default"))) __declspec(dllexport) extern */#define _GLIB_EXTERN __attribute__((visibility("default")))...glib/gmessages.c-------------------------------------------#include //#include //#include -------------------------------------------glib_genmarshalglib-compile-resources-------------------------------------------tests\gobject\Makefile-------------------------------------------# glib_genmarshal = $(top_builddir)/gobject/glib-genmarshalglib_genmarshal = echogio\tests\Makefile-------------------------------------------#glib_compile_resources = $(top_builddir)/gio/glib-compile-resourcesglib_compile_resources = echofix sourcegio/gtype.h add-------------------------------------------void gobj_init(void);gio/gtype.c add-------------------------------------------void gobj_init(void){ gobject_init ();}-------------------------------------------fix tools source-------------------------------------------gio/glib-compile-resources.cgio/glib-compile-schemas.cgio/gio-querymodules.cgio/gsettings-tool.cgio/gresource-tool.cgio/gdbus-tool.cgio/gio-tool.c-------------------------------------------#include "glib-init.h"#include "../gobject/gobject.h"main()... g_clock_win32_init (); g_thread_win32_init (); glib_init (); gobj_init ();...--------------------------------------------------------------------------------------gobject/glib-genmarshal.c <-- Makefile add $(top_builddir)/gobject/libgobject-2.0.la gobject/gobject-query.c -------------------------------------------#include "glib/glib-init.h"#include "gobject.h"main()... g_clock_win32_init (); g_thread_win32_init (); glib_init (); gobj_init ();...------------------------------------------- ------------------------------------------- tests\gobject\performance.c tests\gobject\performance-threaded.c -------------------------------------------#include "glib.h"#include main()... g_clock_win32_init (); g_thread_win32_init (); glib_init (); gobj_init ();...-------------------------------------------#include #include #include int main(void){ g_clock_win32_init (); g_thread_win32_init (); glib_init (); gobj_init (); g_printf("Hello world!\n"); return 0;}gcc hello.c `pkg-config --cflags --static --libs glib-2.0 gobject-2.0` -o hello
cpp 中使用时 需加
extern "C" extern "C" {#include #include #include }链接:http://pan.baidu.com/s/1dFmJmDF 密码:kbsn