使用gtkmm进行编译错误

时间:2016-05-23 16:15:19

标签: c++ eclipse mingw gtkmm msys

我正在尝试使用gtkmm在eclipse上编译一个简单的helloworld程序,并使用mingw32通过mingw32进行编译。

我按照这些说明“安装”gtkmm: https://wiki.gnome.org/Projects/gtkmm/MSWindows

我还阅读了很多关于该主题的主题,但无法理解为什么我无法编译这个简单的程序:

#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);
}

通过eclipse IDE我使用了

  

项目=&GT;属性=&GT; C / C ++构建=&gt;设置=&GT; pkg配置

我启用了gtkmm-3.0。 然后我编译,我得到错误:

Info: Configuration "Debug" uses tool-chain "MinGW GCC" that is unsupported on this system, attempting to build anyway.
Info: Internal Builder is used for build
g++ -I/mingw32/include/gtkmm-3.0 -I/mingw32/lib/gtkmm-3.0/include -I/mingw32/include/atkmm-1.6 -I/mingw32/include/gdkmm-3.0 -I/mingw32/lib/gdkmm-3.0/include -I/mingw32/include/giomm-2.4 -I/mingw32/lib/giomm-2.4/include -I/mingw32/include/pangomm-1.4 -I/mingw32/lib/pangomm-1.4/include -I/mingw32/include/glibmm-2.4 -I/mingw32/lib/glibmm-2.4/include -I/mingw32/include/gtk-3.0 -I/mingw32/include/cairo -I/mingw32/include -I/mingw32/include/pango-1.0 -I/mingw32/include/atk-1.0 -I/mingw32/include/cairomm-1.0 -I/mingw32/lib/cairomm-1.0/include -I/mingw32/include/pixman-1 -I/mingw32/include/freetype2 -I/mingw32/include/libpng16 -I/mingw32/include/harfbuzz -I/mingw32/include/glib-2.0 -I/mingw32/lib/glib-2.0/include -I/mingw32/include/sigc++-2.0 -I/mingw32/lib/sigc++-2.0/include -I/mingw32/include/gdk-pixbuf-2.0 -I/mingw32/includ -O0 -g3 -Wall -c -fmessage-length=0 -std=c++11 -o main.o "..\\main.cpp" 
..\main.cpp:1:19: fatal error: gtkmm.h: No such file or directory
compilation terminated.

奇怪的是,我可以在编译日志中看到它包含了该程序所需的一切。

我也尝试添加

  

project =&gt; properties =&gt; C / C ++ build =&gt; settings =&gt; tool settings =&gt; gcc c ++   编译器和mingw链接器

pkg-config gtkmm-3.0 --cflags --libs的结果,但我得到完全相同的错误。

我花了两天时间阅读并尝试了我到处找到的相同命题,但是没有得到结果。 所以请有人试着帮助我找到一种方法让这个简单的例子起作用。

非常感谢你 (ps:对不起我的错误)

1 个答案:

答案 0 :(得分:0)

我有同样的问题,我通过手动添加所有这个包含的路径来解决它(Project Prorepties&gt; C / C ++ Build&gt; Settings&gt; GCC C ++ Compiler&gt; Includes&gt; Include Paths(-I)):

"C:\msys64\mingw32\include\gtkmm-3.0"
"C:\msys64\mingw32\lib\gtkmm-3.0\include"
"C:\msys64\mingw32\include\glibmm-2.4"
"C:\msys64\mingw32\lib\glibmm-2.4\include"
"C:\msys64\mingw32\include\glib-2.0"
"C:\msys64\mingw32\lib\glib-2.0\include"
"C:\msys64\mingw32\include\sigc++-2.0" 
"C:\msys64\mingw32\lib\sigc++-2.0\include"  
"C:\msys64\mingw32\include\giomm-2.4" 
"C:\msys64\mingw32\lib\giomm-2.4\include"  
"C:\msys64\mingw32\include\gdkmm-3.0"  
"C:\msys64\mingw32\lib\gdkmm-3.0\include"
"C:\msys64\mingw32\include\pangomm-1.4"  
"C:\msys64\mingw32\include\gtk-3.0"  
"C:\msys64\mingw32\include\pango-1.0" 
"C:\msys64\mingw32\lib\pangomm-1.4\include" 
"C:\msys64\mingw32\include\cairo"  
"C:\msys64\mingw32\include\gdk-pixbuf-2.0" 
"C:\msys64\mingw32\include\cairomm-1.0"  
"C:\msys64\mingw32\include\freetype2"   
"C:\msys64\mingw32\include\atkmm-1.6"   
"C:\msys64\mingw32\include\atk-1.0" 
"C:\msys64\mingw32\include\gtkmm-3.0" 
"C:\msys64\mingw32\include\glibmm-2.4"

(你应该用你的mingw32路径替换“C:\ msys64 \ mingw32”)

还添加-std=c++11标志(项目Prorepties&gt; C / C ++ Build&gt;设置&gt; GCC C ++编译器&gt;杂项&gt;其他标志)和

glibmm-2.4
gtkmm-3.0

to(Project Prorepties&gt; C / C ++ Build&gt; Settings&gt; MinGW C ++ Linker&gt; Libraries(-l))