在使用MSYS2 mingw64编译OpenLDAP时仍然面临一些奇怪的编译错误
我认为这归结为一些win socket事物,目前在make depend和make期间面临2个主要错误
在make depend期间
找不到服务器中的nt_err.c / slapd / slapi ==>我从库/ liblber / nt_err.c
中复制了nt_err.c然后出现致命错误,同时依靠slapi。 make使用的命令取决于:make -w -I/usr/include -I/usr/include -I/usr/include -I/usr/include depend
,这可能是因为我已经在主要make中传递了-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
我尝试在./configure之前放置ENV CFLAGS="-I/usr/include"
,导致更多错误,许多.h不可用但存在。和sys / socket.h是可用的和存在。
结果是-I / usr / include以某种方式没有传递给编译器?
我的问题是,这是可配置的吗?或者我的设置有问题吗?
OpenLDAP 2.4.46
MSYS2 20161025
答案 0 :(得分:0)
MSYS2有三个不同用途的工具链:
/usr/bin/gcc
,它使用来自/usr/include
的标头。如果您的程序是为Linux或其他POSIX类型的操作系统编写的,并且您发现很难将其移植到Windows,这是使用的工具链,因为它使用了许多Microsoft不支持的功能。/mingw32/bin/gcc
。要使用此工具链,必须使用“MinGW-w64 32位Shell”快捷方式启动MSYS2或启动mingw32.exe。此工具链不与/usr/include
中的标头兼容,但它可以使用Microsoft定义的接口的本机Windows标头,如windows.h
。mingw64.exe
启动。我对OpenLDAP一无所知,但如果它需要MinGW工具链没有的一堆标头,你可以尝试将其移植到Windows或切换到使用msys-2.0构建它.dll-based toolchain。