简体   繁体   English

Msys2和Mingw64系统包含目录不正确,阻止了GLib的使用

[英]Msys2 and Mingw64 system include directory is incorrect preventing the use of GLib

I am doing C development on windows and installed Msys2. 我正在Windows上进行C开发并安装了Msys2。 With Msys2 pacman I installed 64 bit mingw and Glib. 使用Msys2 pacman我安装了64位mingw和Glib。 I can use the gcc that was installed to compile. 我可以使用已安装的gcc进行编译。 The Glib headers is now at C:\\msys64\\mingw64\\include\\glib-2.0 and C:\\msys64\\usr\\include\\glib-2.0 . Glib标头现在位于C:\\msys64\\mingw64\\include\\glib-2.0C:\\msys64\\usr\\include\\glib-2.0

When adding #include <gmodule.h> to a source file and compiling I get: fatal error: gmodule.h: No such file or directory #include <gmodule.h>添加到源文件并进行编译时,我得到: fatal error: gmodule.h: No such file or directory

Checking the include paths with gcc -xc -E -v - I see errors: 使用gcc -xc -E -v -检查包含路径gcc -xc -E -v -我看到错误:

Using built-in specs.
COLLECT_GCC=gcc
Target: x86_64-w64-mingw32
Configured with: ../gcc-8.2.0/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32 -
-host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include
--libexecdir=/mingw64/lib --enable-bootstrap --with-arch=x86-64 --with-tune=generic --enable-languages=ada,c,lto,c++,objc,obj-c++,fortran --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts=yes --enable-libstdcxx-time=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --disable-isl-version-check --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='Rev1, Built by MSYS2 project' --with-bugurl=https://sourceforge.net/projects/msys2 --with-gnu-as --with-gnu-ld
Thread model: posix
gcc version 8.2.0 (Rev1, Built by MSYS2 project)
COLLECT_GCC_OPTIONS='-E' '-v' '-mtune=generic' '-march=x86-64'
 C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/cc1.exe -E -quiet -v -iprefix C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/ -D_REENTRANT - -mtune=generic -march=x86-64
ignoring duplicate directory "C:/msys64/mingw64/lib/gcc/../../lib/gc/x86_64-w64-mingw32/8.2.0/include"
ignoring nonexistent directory "F:/msys64/mingw64/include"
ignoring nonexistent directory "/mingw64/include"
ignoring duplicate directory "C:/msys64/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/8.2.0/include-fixed"
ignoring duplicate directory "C:/msys64/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/include"
ignoring nonexistent directory "F:/msys64/mingw64/x86_64-w64-mingw32/include"
#include "..." search starts here:
#include <...> search starts here:
 C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/include
 C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../include
 C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/include-fixed
 C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/include
End of search list.

How do I fix include paths so that gcc can find the GLib headers? 如何修复包含路径,以便gcc可以找到GLib标头? I could add it to a spec file or C_INCLUDE_PATH but I it bypasses the error instead of fixing it. 我可以将其添加到规范文件或C_INCLUDE_PATH但是我绕过了该错误而不是对其进行了修复。

If you install pkg-config , you can use it to obtain the build flags for glib, like this: 如果安装pkg-config ,则可以使用它来获取glib的构建标志,如下所示:

$ pkg-config --cflags glib-2.0
-I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include
$ pkg-config --libs glib-2.0       
$ -lglib-2.0

The flags will vary from system to system, but the library name ( glib-2.0 ) is hopefully consistent. 这些标志因系统而异,但是库名( glib-2.0 )希望是一致的。

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

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