【问题标题】:configure cc1 include path配置cc1包含路径
【发布时间】:2018-11-22 10:34:07
【问题描述】:

在使用 MSYS2 mingw64 编译 OpenLDAP 时仍然遇到一些奇怪的编译错误

我认为这归结为一些 win socket 的事情,目前在 make depend 和 make 期间面临 2 个主要错误

在 make 依赖期间

无法在 servers/slapd/slapi 中找到 nt_err.c ==> 我求助于从 libraries/liblber/nt_err.c 复制 nt_err.c

然后在 slapi 中 make 依赖时出现致命错误。 makedepend使用的命令:make -w -I/usr/include -I/usr/include -I/usr/include -I/usr/include depend,可能是因为我在主makedepend中通过了-I/usr/include

但还是

Entering directory '/home/Jimmy/openldapsrc/openldap-2.4.46/servers/slapd/slapi'
../../../build/mkdep -l -d "." -c "cc" -m "-M" -I../../../include -I.. -I.        -I../../../include -I./.. -I.     plugin.c slapi_pblock.c slapi_utils.c printmsg.c slapi_ops.c slapi_dn.c slapi_ext.c slapi_overlay.c nt_err.c
In file included from slapi_utils.c:34:0:
../../../include/netdb.h:73:10: fatal error: netinet/in.h: No such file or directory
 #include <netinet/in.h>
          ^~~~~~~~~~~~~~
compilation terminated.

实际上我已经看到了很多类似的错误,例如在make期间它也会在slapi中给出错误

No such file or directory
#include <sys/socket.h>
          ^~~~~~~~~~~~~~
compilation terminated.

我检查了pacman -Fs in.h socket.h,输出如下

msys/msys2-runtime-devel 2.10.0-2
    usr/include/cygwin/in.h
    usr/include/netinet/in.h
    usr/include/sys/socket.h

我已经安装了 msys2-runtime-devel。尽管如此,这提醒我,在 ./configure 输出包含

checking sys/socket.h usability... no
checking sys/socket.h presence... no

所以我尝试运行gcc -xc -E -v - 试图确定包含哪个目录,但是在 MSYS2-MINGW64 中它停止了

COLLECT_GCC=C:\msys64\mingw64\bin\gcc.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-7.3.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=c,lto,c++,objc,obj-c++,fortran,ada --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-time=yes --enable-libstdcxx-filesystem-ts=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 7.3.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/7.3.0/cc1.exe -E -quiet -v -iprefix C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/ -D_REENTRANT - -mtune=generic -march=x86-64

cc1 没有输出,冻结了 MSYS2,我必须从任务管理器中终止 cc1。

那我直接跑C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/cc1.exe -E -quiet -v -iprefix C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/ -D_REENTRANT - -mtune=generic -march=x86-64

它返回了

ignoring duplicate directory "C:/msys64/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/7.3.0/include"
ignoring nonexistent directory "C:/building/msys64/mingw64/include"
ignoring nonexistent directory "/mingw64/include"
ignoring duplicate directory "C:/msys64/mingw64/lib/gcc/../../lib/gcc/x86_64- w64-mingw32/7.3.0/include-fixed"
ignoring duplicate directory "C:/msys64/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/include"
ignoring nonexistent directory "C:/building/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/7.3.0/include
 C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64- mingw32/7.3.0/../../../../include
 C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/include-fixed
 C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/include
End of search list.

原来#include &lt;...&gt; search不包括MSYS2的/usr/include目录,应该是C:/msys64/mingw64/bin/../../usr/include

我尝试将ENV CFLAGS="-I/usr/include" 放在./configure 之前,这会导致更多错误,许多.h 不可用但存在。并且 sys/socket.h 可用且存在。

结果是 -I/usr/include 不知何故没有传入编译器?

我的问题是,这是可配置的吗?还是我的设置有问题?

OpenLDAP 2.4.46

MSYS2 20161025

【问题讨论】:

    标签: openldap msys2 cc


    【解决方案1】:

    MSYS2 具有三个不同用途的不同工具链:

    1. 基于 msys-2.0.dll 的工具链,它创建使用 msys-2.0.dll 提供的 POSIX 仿真功能的可执行文件。主编译器是/usr/bin/gcc,它使用来自/usr/include 的头文件。如果您的程序是为 Linux 或其他 POSIX 类型的操作系统编写的,并且您发现很难将其移植到 Windows,则可以使用此工具链,因为它使用了许多 Microsoft 不支持的功能。
    2. MinGW 32 位工具链。这会编译可以在 32 位或 64 位版本的 Windows 上运行的本机 Windows 软件。主编译器是/mingw32/bin/gcc。要使用此工具链,您必须使用“MinGW-w64 32-bit Shell”快捷方式启动 MSYS2 或启动 mingw32.exe。此工具链/usr/include 中的标头兼容,但它可以使用带有 Microsoft 定义的接口的原生 Windows 标头,例如 windows.h
    3. MinGW 64 位工具链。该工具链与 32 位工具链一样,只是可执行文件是 64 位可执行文件,因此只能在 64 位 Windows 上运行。它在开始菜单中有自己的快捷方式,也可以使用mingw64.exe 启动。

    我对 OpenLDAP 一无所知,但如果它需要一堆 MinGW 工具链所没有的标头,您可以尝试将其移植到 Windows 或切换到使用 msys-2.0 构建它基于 .dll 的工具链。

    【讨论】:

      猜你喜欢
      • 2019-04-21
      • 1970-01-01
      • 1970-01-01
      • 2015-08-16
      • 2021-11-18
      • 2017-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多