gtkmm-3.0:程序生成使用pkg-config使Msys2 Netbeans失败

时间:2017-12-08 11:17:27

标签: c++ netbeans gtk gtkmm msys2

Net-beans:8.2

Windows:10 64位

MinGW-w64 g ++:7.2

我正在尝试使用gtkmm 3.0创建一个空窗口,参考使用gtkmm book编程。我指的是(3.1)第3章基础的简单例子

#include <gtkmm.h>

int main(int argc, char *argv[])
{
  auto app = Gtk::Application::create(argc, argv, "org.gtkmm.examples.base");

  Gtk::Window window;
  window.set_default_size(200, 200);

  return app->run(window);
}

我试过了两次

#include <gtkmm-3.0/gtkmm.h>
#include <gtkmm.h>

但是我的构建在两种情况下都失败了。

g++    -c -g `pkg-config --cflags gtkmm-3.0` -std=c++14  -MMD -MP -MF "build/Debug/MinGW-Windows/main.o.d" -o build/Debug/MinGW-Windows/main.o main.cpp
Package gtkmm-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtkmm-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtkmm-3.0' found
main.cpp:14:10: fatal error: gtkmm.h: No such file or directory
 #include <gtkmm.h>
          ^~~~~~~~~
compilation terminated.
make[2]: *** [nbproject/Makefile-Debug.mk:68: build/Debug/MinGW-Windows/main.o] Error 1
make[2]: Leaving directory '/e/Projects/DiaplayL'
make[1]: *** [nbproject/Makefile-Debug.mk:59: .build-conf] Error 2
make[1]: Leaving directory '/e/Projects/DiaplayL'
make: *** [nbproject/Makefile-impl.mk:40: .build-impl] Error 2

BUILD FAILED (exit value 2, total time: 1s)

我在E盘中安装了msys2。我无法在C盘中安装msys2,因为安装卡在0%。

我在环境变量中添加了PKG_CONFIG_PATH: - E:\ msys64 \ mingw64 \ bin。我可以使用--lbss

查看使用--cflags和链接库的include目录
E:\Projects\DemoLcd>pkg-config --cflags gtkmm-3.0
-mms-bitfields -pthread -mms-bitfields -IE:/msys64/mingw64/include/gtkmm-3.0 -IE:/msys64/mingw64/lib/gtkmm-3.0/include -IE:/msys64/mingw64/include/atkmm-1.6 -IE:/msys64/mingw64/include/gdkmm-3.0 -IE:/msys64/mingw64/lib/gdkmm-3.0/include -IE:/msys64/mingw64/include/giomm-2.4 -IE:/msys64/mingw64/lib/giomm-2.4/include -IE:/msys64/mingw64/include/pangomm-1.4 -IE:/msys64/mingw64/lib/pangomm-1.4/include -IE:/msys64/mingw64/include/glibmm-2.4 -IE:/msys64/mingw64/lib/glibmm-2.4/include -IE:/msys64/mingw64/include/gtk-3.0 -IE:/msys64/mingw64/include/cairo -IE:/msys64/mingw64/include -IE:/msys64/mingw64/include/pango-1.0 -IE:/msys64/mingw64/include/atk-1.0 -IE:/msys64/mingw64/include/cairo -IE:/msys64/mingw64/include/cairomm-1.0 -IE:/msys64/mingw64/lib/cairomm-1.0/include -IE:/msys64/mingw64/include/cairo -IE:/msys64/mingw64/include/pixman-1 -IE:/msys64/mingw64/include -IE:/msys64/mingw64/include/freetype2 -IE:/msys64/mingw64/include/libpng16 -IE:/msys64/mingw64/include/harfbuzz -IE:/msys64/mingw64/include/glib-2.0 -IE:/msys64/mingw64/lib/glib-2.0/include -IE:/msys64/mingw64/include -IE:/msys64/mingw64/include/freetype2 -IE:/msys64/mingw64/include -IE:/msys64/mingw64/include/harfbuzz -IE:/msys64/mingw64/include/libpng16 -IE:/msys64/mingw64/include/sigc++-2.0 -IE:/msys64/mingw64/lib/sigc++-2.0/include -IE:/msys64/mingw64/include/gdk-pixbuf-2.0 -IE:/msys64/mingw64/include/libpng16 -IE:/msys64/mingw64/include -IE:/msys64/mingw64/include/glib-2.0 -IE:/msys64/mingw64/lib/glib-2.0/include -IE:/msys64/mingw64/include

E:\Projects\DemoLcd>pkg-config --libs gtkmm-3.0
-LE:/msys64/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 -lpangowin32-1.0 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lgio-2.0 -lcairomm-1.0 -lcairo -lsigc-2.0 -lgdk_pixbuf-2.0 -lgobject-2.0 -lglib-2.0 -lintl

我在其他机器上面临同样的问题,其中msys2安装在C盘中并且没有任何故障安装。

请提供建议。

1 个答案:

答案 0 :(得分:0)

解决方案有两个步骤:

  1. 修改Msys2 shell中的$ PKG_CONFIG_PATH,以包含包含各个包的.pc文件的pkg_config文件夹。例如:export PKG_CONFIG_PATH = $ PKG_CONFIG_PATH:/ mingw64 / lib / pkgconfig或在/ home //中添加上述命令.bashrc
  2. 创建PKG_CONFIG_PATH环境变量,其值为Linux类型路径,即包含各个包的.pc文件的pkg_config文件夹的/ mingw64 / lib / pkgconfig。例如:PKG_CONFIG_PATH = / mingw64 / lib / pkgconfig