简体   繁体   English

msys2和标头在“错误的”位置

[英]msys2 and headers in the 'wrong' place

Ok, so, I'm trying to build a third party library with msys2 and I've run into a problem with a few headers, such as gtk.h; 好的,所以,我试图使用msys2构建第三方库,但是遇到了一些标头(例如gtk.h)的问题。 the library I'm trying to build expects this to be located via #include <gtk/gtk.h> . 我尝试构建的库希望通过#include <gtk/gtk.h>定位该库。

Now, experience on Linux tells me that would be correct under a normal linux environment; 现在,Linux上的经验告诉我,在正常的Linux环境下这将是正确的。 however, in the case of gtk, it seems it would have to be gtk-3.0/gtk/gtk.h, which seems like an error in msys to me - is there some sort of selection step I've missed in setting up my msys2 environment? 但是,对于gtk,它似乎必须是gtk-3.0 / gtk / gtk.h,这对我来说似乎是msys中的错误-在设置我的设备时是否错过了某些选择步骤msys2环境? Like the 'eselect' system under Gentoo, something like 'pselect gtk-3.0' that would create a linked directory to gtk-3.0/gtk just called gtk? 就像Gentoo下的'eselect'系统一样,类似'pselect gtk-3.0'这样的东西会创建一个到gtk-3.0 / gtk的链接目录,称为gtk?

Assuming that you have installed the mingw-w64-i686-gtk3 package with pacman and that you are running in a MinGW 32-bit shell (MSYS2 has three different flavors of shell that use different toolchains), you can run this command to get the required compile flags for GTK3: 假设您已将mingw-w64-i686-gtk3软件包与pacman一起安装,并且您在MinGW 32位Shell中运行(MSYS2具有使用不同工具链的三种不同口味的Shell),则可以运行此命令来获取GTK3所需的编译标志:

pkg-config gtk+-3.0 --cflags

Most build systems have some kind of support for calling pkg-config . 大多数构建系统都支持调用pkg-config It is basically the standard way to get information about your dependencies. 基本上,这是获取有关依赖项信息的标准方法。

When it's time to link your program, you should replace --cflags in the comand above with --libs . 当需要链接程序时,应使用--cflags替换上面--cflags中的--libs

您只需要告诉编译器在哪里可以找到include目录:

-I/some/path/to/gtk-3.0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM