如何在Windows上编译libevent2?

发布于 2024-12-29 01:43:44 字数 1932 浏览 4 评论 0原文

我正在尝试编译 此 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

I am trying to compile this libevent2 package to Windows, but currently I can't because the configure script is a shell script (/bin/sh; can't be run in Windows).

Is there any way I can compile it or obtain a pre-compiled package? I currently have MinGW, CMake and MS C++ installed.

EDIT: I have managed to compile libevent2 using nmake Makefile.nmake but it hasn't produced any Windows binaries/libraries. Only .lib.

The makefile is as follows -

# 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

俏︾媚 2025-01-05 01:43:44

.lib 文件是 Windows 二进制文件。它是一个静态库文件,由应用程序中的链接器用来静态链接(即通俗地说“使用”)该库。

由于 libevent2 不是程序,因此您不会获得 .exe 输出 - 它将是一个大 .dll + 小 .lib (用于动态链接)或一个大 .lib (用于静态链接)。

A .lib file is a Windows binary file. It's a static library file, and is used by the linker in your application to statically link against (i.e. "use" in layman terms) the library.

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).

明媚如初 2025-01-05 01:43:44

使用Cygwin进行编译。这是一个类似于 Linux 的模拟。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文