无法在Windows上构建libevent

时间:2018-07-25 06:24:52

标签: c windows libevent

所以我一直在尝试在Windows上构建libevent。但是,当我运行nmake MakeFile.nmake ...

时,它一直为我提供以下输出
        cl /IWIN32-Code /IWIN32-Code/nmake /Iinclude /Icompat /DHAVE_CONFIG_H /I.  
/Ox /W3 /wd4996 /nologo /c event.c buffer.c bufferevent.c bufferevent_sock.c bufferevent_pair.c 
listener.c evmap.c log.c evutil.c strlcpy.c signal.c bufferevent_filter.c evthread.c bufferevent_ratelim.c 
evutil_rand.c evutil_time.c win32select.c evthread_win32.c buffer_iocp.c event_iocp.c bufferevent_async.c 
event.c
event.c(31): fatal error C1083: Cannot open include file: 'winsock2.h': No such file or directory
buffer.c
buffer.c(32): fatal error C1083: Cannot open include file: 'winsock2.h': No such file or directory
bufferevent.c
bufferevent.c(31): fatal error C1083: Cannot open include file: 'sys/types.h': No such file or directory
bufferevent_sock.c
bufferevent_sock.c(32): fatal error C1083: Cannot open include file: 'sys/types.h': No such file or directory
bufferevent_pair.c
bufferevent_pair.c(29): fatal error C1083: Cannot open include file: 'sys/types.h': No such file or directory
listener.c
listener.c(30): fatal error C1083: Cannot open include file: 'sys/types.h': No such file or directory
evmap.c
evmap.c(30): fatal error C1083: Cannot open include file: 'winsock2.h': No such file or directory
log.c
log.c(44): fatal error C1083: Cannot open include file: 'winsock2.h': No such file or directory
evutil.c
evutil.c(31): fatal error C1083: Cannot open include file: 'winsock2.h': No such file or directory
strlcpy.c
strlcpy.c(37): fatal error C1083: Cannot open include file: 'sys/types.h': No such file or directory
signal.c
signal.c(34): fatal error C1083: Cannot open include file: 'winsock2.h': No such file or directory
bufferevent_filter.c
bufferevent_filter.c(31): fatal error C1083: Cannot open include file: 'sys/types.h': No such file or directory
evthread.c
evthread.c(34): fatal error C1083: Cannot open include file: 'stdlib.h': No such file or directory
bufferevent_ratelim.c
bufferevent_ratelim.c(30): fatal error C1083: Cannot open include file: 'sys/types.h': No such file or directory
evutil_rand.c
evutil_rand.c(38): fatal error C1083: Cannot open include file: 'limits.h': No such file or directory
evutil_time.c
evutil_time.c(31): fatal error C1083: Cannot open include file: 'winsock2.h': No such file or directory
win32select.c
win32select.c(33): fatal error C1083: Cannot open include file: 'winsock2.h': No such file or directory
evthread_win32.c
evthread_win32.c(34): fatal error C1083: Cannot open include file: 'winsock2.h': No such file or directory
buffer_iocp.c
include\event2/buffer.h(82): fatal error C1083: Cannot open include file: 'stdarg.h': No such file or directory
event_iocp.c
event_iocp.c(32): fatal error C1083: Cannot open include file: 'winsock2.h': No such file or directory
Generating Code...
Compiling...
bufferevent_async.c
bufferevent_async.c(36): fatal error C1083: Cannot open include file: 'errno.h': No such file or directory
Generating Code...
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0
\VC\bin\cl.EXE"' : return code '0x2'
Stop.

似乎无法找到某些文件。因此,我找到了winsock2.h和其他文件所在的目录,并向这些文件添加了环境变量,但是仍然出现相同的错误。我还注意到,在我的系统上实际上找不到sys / types.h和limits.h。如果有人可以帮助您找出导致此问题的原因,我将不胜感激。谢谢。

更新: 因此,我确定了系统上所有所需文件的位置,并尝试将环境变量添加到适当的目录中,但是,在运行nmake时仍然找不到它们。

1 个答案:

答案 0 :(得分:0)

libevent README.md文件不建议使用nmake。它指向您使用CMake和现有的Makefile.nmake在顶部有一个很大的注释,表明它可能不起作用。因此,请安装cmake(您可以使用Chocolatey'choco install cmake'),然后按文档所述运行命令。

<html>
<iframe width="560" height="315" src="https://www.youtube.com/embed/1wUgMEaUUrM?rel=0&amp;controls=0&amp;showinfo=0&amp;autoplay=1&amp;start=40&amp;loop=1"
    frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
 </html>

这对我使用Visual Studio 2017和分支release-2.1.8-stable的git checkout一起工作。我添加了disable-openssl选项,因为它没有此选项就失败了,我不想花时间单独安装它。