安装gtkmm环境
参考地址:https://wiki.gnome.org/Projects/gtkmm/MSWindows
安装步骤:
1.下载msys2:http://www.msys2.org/
2.选择安装组件
To install the one targeting i686:
pacman -S mingw-w64-i686-gcc
To install the one targeting x86_64:
pacman -S mingw-w64-x86_64-gcc
Similarly, you need to install the gtkmm libs:
pacman -S mingw-w64-i686-gtkmm3
and/or
pacman -S mingw-w64-x86_64-gtkmm3
You will probably also want pkg-config:
pacman -S pkg-config
必须安装:pacman -S make
可选安装:pacman -S vim
3.安装完成后,启动msys控制台编写如下代码
#include <gtkmm.h>
int main(int argc, char *argv[])
{
Gtk::Main kit(argc, argv);
Gtk::Window window;
Gtk::Main::run(window);
return 0;
}
或者
//foo.cpp
#include <gtkmm.h>
int main(int argc, char** argv)
{
auto app = Gtk::Application::create(argc, argv);
Gtk::Window window;
window.set_default_size(600,400);
return app->run(window);
}
4.执行命令:
g++ -std=c++11 foo.cpp $(pkg-config gtkmm-3.0 --cflags --libs | sed 's/ -I/ -isystem /g')
即可看到界面
则表示安装成功
配置eclipse环境编辑
配置eclipse环境相对比较繁琐,希望gtkmm官方早日有自己的IDE编辑
第一步:
安装CDT的eclipse环境,前提需要配置好MingGW与msys,配置完毕后,可以正常编译执行c\c++程序即可
第二步:
新建源码工程,并参考如图设置,注意一定要参考如图设置,注意不论Debug还是Release都需要设置
第三步:
设置完毕后选择:All configurations
第四步:
而后选择Setting参考如图:
其中E:\2017\msys64\mingw64\include\gtkmm-3.0\gtkmm
为实际安装目录,注意一定要添加此项目录,否则代码不能有提示功能。
全部配置完毕如下:
E:/2017/msys64/mingw64/include/gtkmm-3.0
E:/2017/msys64/mingw64/lib/gtkmm-3.0/include
E:/2017/msys64/mingw64/include/atkmm-1.6
E:/2017/msys64/mingw64/include/gdkmm-3.0
E:/2017/msys64/mingw64/lib/gdkmm-3.0/include
E:/2017/msys64/mingw64/include/giomm-2.4
E:/2017/msys64/mingw64/lib/giomm-2.4/include
E:/2017/msys64/mingw64/include/pangomm-1.4
E:/2017/msys64/mingw64/lib/pangomm-1.4/include
E:/2017/msys64/mingw64/include/glibmm-2.4
E:/2017/msys64/mingw64/lib/glibmm-2.4/include
E:/2017/msys64/mingw64/include/gtk-3.0
E:/2017/msys64/mingw64/include/cairo
E:/2017/msys64/mingw64/include
E:/2017/msys64/mingw64/include/pango-1.0
E:/2017/msys64/mingw64/include/atk-1.0
E:/2017/msys64/mingw64/include/cairo
E:/2017/msys64/mingw64/include/cairomm-1.0
E:/2017/msys64/mingw64/lib/cairomm-1.0/include
E:/2017/msys64/mingw64/include/cairo
E:/2017/msys64/mingw64/include/pixman-1
E:/2017/msys64/mingw64/include
E:/2017/msys64/mingw64/include/freetype2
E:/2017/msys64/mingw64/include/libpng16
E:/2017/msys64/mingw64/include/harfbuzz
E:/2017/msys64/mingw64/include/glib-2.0
E:/2017/msys64/mingw64/lib/glib-2.0/include
E:/2017/msys64/mingw64/include
E:/2017/msys64/mingw64/include/freetype2
E:/2017/msys64/mingw64/include
E:/2017/msys64/mingw64/include/harfbuzz
E:/2017/msys64/mingw64/include
E:/2017/msys64/mingw64/include/libpng16
E:/2017/msys64/mingw64/include/sigc++-2.0
E:/2017/msys64/mingw64/lib/sigc++-2.0/include
E:/2017/msys64/mingw64/include/gdk-pixbuf-2.0
E:/2017/msys64/mingw64/include/libpng16
E:/2017/msys64/mingw64/include/glib-2.0
E:/2017/msys64/mingw64/lib/glib-2.0/include
E:/2017/msys64/mingw64/include
分别配置编译和链接
配置内容参考:
对应第一张图配置内容
-c -fmessage-length=0 -mms-bitfields -pthread -mms-bitfields -I/mingw64/include/gtkmm-3.0 -I/mingw64/lib/gtkmm-3.0/include -I/mingw64/include/atkmm-1.6 -I/mingw64/include/gdkmm-3.0 -I/mingw64/lib/gdkmm-3.0/include -I/mingw64/include/giomm-2.4 -I/mingw64/lib/giomm-2.4/include -I/mingw64/include/pangomm-1.4 -I/mingw64/lib/pangomm-1.4/include -I/mingw64/include/glibmm-2.4 -I/mingw64/lib/glibmm-2.4/include -I/mingw64/include/gtk-3.0 -I/mingw64/include/cairo -I/mingw64/include -I/mingw64/include/pango-1.0 -I/mingw64/include/atk-1.0 -I/mingw64/include/cairo -I/mingw64/include/cairomm-1.0 -I/mingw64/lib/cairomm-1.0/include -I/mingw64/include/cairo -I/mingw64/include/pixman-1 -I/mingw64/include -I/mingw64/include/freetype2 -I/mingw64/include/libpng16 -I/mingw64/include/harfbuzz -I/mingw64/include/glib-2.0 -I/mingw64/lib/glib-2.0/include -I/mingw64/include -I/mingw64/include/freetype2 -I/mingw64/include -I/mingw64/include/harfbuzz -I/mingw64/include -I/mingw64/include/libpng16 -I/mingw64/include/sigc++-2.0 -I/mingw64/lib/sigc++-2.0/include -I/mingw64/include/gdk-pixbuf-2.0 -I/mingw64/include/libpng16 -I/mingw64/include/glib-2.0 -I/mingw64/lib/glib-2.0/include -I/mingw64/include
对应第二张图图配置内容
-L/mingw64/lib -LC:/building/msys64/mingw64/lib -L/mingw64/lib -LC:/building/msys64/mingw64/lib/../lib -L/mingw64/lib -LC:/building/msys64/mingw64/lib -L/mingw64/lib -lgtkmm-3.0 -latkmm-1.6 -lgdkmm-3.0 -lgiomm-2.4 -lpangomm-1.4 -lglibmm-2.4 -lgtk-3 -lgdk-3 -lgdi32 -limm32 -lshell32 -lole32 -Wl,-luuid -lwinmm -ldwmapi -lsetupapi -lcfgmgr32 -lz -lepoxy -lpangocairo-1.0 -lpangoft2-1.0 -lpangowin32-1.0 -lgdi32 -lusp10 -lpango-1.0 -lm -latk-1.0 -lcairo-gobject -lgio-2.0 -lz -lcairomm-1.0 -lcairo -lz -lpixman-1 -lfontconfig -lexpat -lfreetype -liconv -lexpat -lfreetype -lz -lbz2 -lharfbuzz -lgraphite2 -lpng16 -lz -lsigc-2.0 -lgdk_pixbuf-2.0 -lgmodule-2.0 -pthread -lpng16 -lz -lgobject-2.0 -lffi -lglib-2.0 -lintl -pthread -lws2_32 -lole32 -lwinmm -lshlwapi -lpcre -lintl -lpcre
备注:具体内容,通过执行
pkg-config --cflags gtkmm-3.0
pkg-config --libs gtkmm-3.0
命令即可得到,暂时只能通过此方法配置,其他配置均无效
Administrator@USER-20170324BD MINGW64 ~
$ pkg-config --cflags gtkmm-3.0
-mms-bitfields -pthread -mms-bitfields -I/mingw64/include/gtkmm-3.0 -I/mingw64/lib/gtkmm-3.0/include -I/mingw64/include/atkmm-1.6 -I/mingw64/include/gdkmm-3.0 -I/mingw64/lib/gdkmm-3.0/include -I/mingw64/include/giomm-2.4 -I/mingw64/lib/giomm-2.4/include -I/mingw64/include/pangomm-1.4 -I/mingw64/lib/pangomm-1.4/include -I/mingw64/include/glibmm-2.4 -I/mingw64/lib/glibmm-2.4/include -I/mingw64/include/gtk-3.0 -I/mingw64/include/cairo -I/mingw64/include -I/mingw64/include/pango-1.0 -I/mingw64/include/atk-1.0 -I/mingw64/include/cairo -I/mingw64/include/cairomm-1.0 -I/mingw64/lib/cairomm-1.0/include -I/mingw64/include/cairo -I/mingw64/include/pixman-1 -I/mingw64/include -I/mingw64/include/freetype2 -I/mingw64/include/libpng16 -I/mingw64/include/harfbuzz -I/mingw64/include/glib-2.0 -I/mingw64/lib/glib-2.0/include -I/mingw64/include -I/mingw64/include/freetype2 -I/mingw64/include -I/mingw64/include/harfbuzz -I/mingw64/include -I/mingw64/include/libpng16 -I/mingw64/include/sigc++-2.0 -I/mingw64/lib/sigc++-2.0/include -I/mingw64/include/gdk-pixbuf-2.0 -I/mingw64/include/libpng16 -I/mingw64/include/glib-2.0 -I/mingw64/lib/glib-2.0/include -I/mingw64/include
Administrator@USER-20170324BD MINGW64 ~
$ pkg-config --libs gtkmm-3.0
-L/mingw64/lib -LC:/building/msys64/mingw64/lib -L/mingw64/lib -LC:/building/msys64/mingw64/lib/../lib -L/mingw64/lib -LC:/building/msys64/mingw64/lib -L/mingw64/lib -lgtkmm-3.0 -latkmm-1.6 -lgdkmm-3.0 -lgiomm-2.4 -lpangomm-1.4 -lglibmm-2.4 -lgtk-3 -lgdk-3 -lgdi32 -limm32 -lshell32 -lole32 -Wl,-luuid -lwinmm -ldwmapi -lsetupapi -lcfgmgr32 -lz -lepoxy -lpangocairo-1.0 -lpangoft2-1.0 -lpangowin32-1.0 -lgdi32 -lusp10 -lpango-1.0 -lm -latk-1.0 -lcairo-gobject -lgio-2.0 -lz -lcairomm-1.0 -lcairo -lz -lpixman-1 -lfontconfig -lexpat -lfreetype -liconv -lexpat -lfreetype -lz -lbz2 -lharfbuzz -lgraphite2 -lpng16 -lz -lsigc-2.0 -lgdk_pixbuf-2.0 -lgmodule-2.0 -pthread -lpng16 -lz -lgobject-2.0 -lffi -lglib-2.0 -lintl -pthread -lws2_32 -lole32 -lwinmm -lshlwapi -lpcre -lintl -lpcre
第五步:
到这里就已经配置成功, 编译或者运行即可看到如下结果界面