【发布时间】: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 <...> 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
【问题讨论】: