1

我正在尝试将此 libevent2 包编译到 Windows,但目前我不能,因为配置脚本是一个 shell 脚本(/bin/sh;不能在 Windows 中运行)。

有什么方法可以编译它或获得预编译包?我目前安装了 MinGW、CMake 和 MS C++。

编辑:我已经设法使用nmake Makefile.nmake编译 libevent2,但它没有生成任何 Windows 二进制文件/库。只有.lib。

生成文件如下 -

# WATCH OUT!  This makefile is a work in progress.  It is probably missing
# tons of important things.  DO NOT RELY ON IT TO BUILD A GOOD LIBEVENT.

# Needed for correctness
CFLAGS=/IWIN32-Code /Iinclude /Icompat /DWIN32 /DHAVE_CONFIG_H /I.

# For optimization and warnings
CFLAGS=$(CFLAGS) /Ox /W3 /wd4996 /nologo

# XXXX have a debug mode

LIBFLAGS=/nologo

CORE_OBJS=event.obj buffer.obj bufferevent.obj bufferevent_sock.obj \
    bufferevent_pair.obj listener.obj evmap.obj log.obj evutil.obj \
    strlcpy.obj signal.obj bufferevent_filter.obj evthread.obj \
    bufferevent_ratelim.obj evutil_rand.obj
WIN_OBJS=win32select.obj evthread_win32.obj buffer_iocp.obj \
    event_iocp.obj bufferevent_async.obj
EXTRA_OBJS=event_tagging.obj http.obj evdns.obj evrpc.obj

ALL_OBJS=$(CORE_OBJS) $(WIN_OBJS) $(EXTRA_OBJS)
STATIC_LIBS=libevent_core.lib libevent_extras.lib libevent.lib


all: static_libs tests

static_libs: $(STATIC_LIBS)

libevent_core.lib: $(CORE_OBJS) $(WIN_OBJS)
    lib $(LIBFLAGS) $(CORE_OBJS) $(WIN_OBJS) /out:libevent_core.lib 

libevent_extras.lib: $(EXTRA_OBJS)
    lib $(LIBFLAGS) $(EXTRA_OBJS) /out:libevent_extras.lib

libevent.lib: $(CORE_OBJS) $(WIN_OBJS) $(EXTRA_OBJS)
    lib $(LIBFLAGS) $(CORE_OBJS) $(EXTRA_OBJS) $(WIN_OBJS) /out:libevent.lib

clean:
    del $(ALL_OBJS)
    del $(STATIC_LIBS)
    cd test
    $(MAKE) /F Makefile.nmake clean

tests:
    cd test
    $(MAKE) /F Makefile.nmake
4

2 回答 2

5

.lib 文件Windows 二进制文件。它是一个静态库文件,应用程序中的链接器使用它来静态链接(即外行术语中的“使用”)库。

Since libevent2 is not a program, you won't get a .exe output - it'll be either a big .dll + small .lib (for dynamic linking) or a big .lib (for static linking).

于 2012-01-26T02:10:32.723 回答
0

Use Cygwin to compile. It's a Linux emulation like.

于 2012-01-26T02:24:02.933 回答