[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] using libEvent 2.x with Visual C++



On 06/06/2012 06:57 AM, Nick Mathewson wrote:

(since libEvent doesn't seem to have an equivalent to
OpenSSL's "applink.c" that bridges between the two compilers' runtimes)

(I'd sure like to have one of those, fwiw.)

If that's something you'd like, then I might look into that as an alternative to getting libevent itself compiling with MSVC. I'm more of a coder than a build guy, so it seems more in my comfort zone. It should be pretty simple conceptually, although I suspect it will touch a lot of code. So if you don't mind accepting a big patch, I might explore this option.

It should work with any reasonably cc-like compiler on any reasonably
posix-like host.

This of course does -not- include MSVC.

Getting a bit off topic, but I wonder if anyone has tried to make a wrapper script for CL.EXE that makes it look more like gcc, in terms of command line options. (Though it would probably need to do other nasty tricks, like renaming .OBJ files to .o, and .LIB files to .a, and then rename them back again when linking.)

Hm.  What version of Libevent were you trying with?  Could you attach
the actual error you're getting?

I'm using the bleeding-edge version (0bbd850cc077e5555128f5b6dfce00a54b65526b) straight off of git://github.com/libevent/libevent.git, on the theory that if there were any recent Windows fixes, I'd want to get them. (The flipside being that if there are any recent Windows breakages, I get them, too.)

I've attached the errors I'm getting. (Hoping the attachment will go through the mailing list okay, but I don't know.) I'm sure I can track them down and fix them, but first I just wanted to touch base and find out whether I'm completely barking up the wrong tree with Makefile.nmake.

Correct.  I'd like to fix that, but my DLL expertise is extremely
limited.  Any help there would be much appreciated.

I'm afraid my Windows knowledge is relatively limited, too. I'm mostly a Linux guy, but since our company is mostly Linux and OS X, I'm one of the more Windows-knowledgeable people here. Although there are a few other people with Windows knowledge I might be able to rope into this project. (Although I'm trying to mostly handle it myself, because I already promised my boss that libevent is supported on all the platforms we target, and then I belatedly realized it doesn't support MSVC very well.)

I'm not sure, since I don't know what's going to be required to make
it emit DLLs for you.  If it's easy to do that via Makefile.nmake, I'd
be in favor of it.

I suppose I'm not even 100% sure I need a libevent DLL. The code I'm working on needs to be compiled into a DLL, and it would depend on libevent. Coming from the Linux world, I'm generally under the impression that shared libraries can't depend on static libraries, since shared libraries are PIC and static libraries are non-PIC. But my understanding is that Windows never uses PIC, even for DLLs, so perhaps on Windows it's possible to just "suck in" a static library (libevent) when building a DLL (my library), such that libevent would just become part of my DLL, rather than a separate DLL. But I don't know; this is way outside the depth of my build knowledge.

re cmake: From time to time people have tried to write cmakefiles for
Libevent.  I haven't accepted them as a replacement for the
autotools-based build process, since such efforts have inevitably
omitted multiple checks that the autotools build does.  But as an
*alternative* build process, it would be cool to have something like
that.  A little searching should find previous efforts in this area
that you might be able to build on.

Okay, I'll investigate the nmake option a bit more (though I'm afraid I know nothing about nmake; our own Windows builds are done with .vcxproj files that were partially created with the Visual Studio GUI, partially edited by hand with Emacs, and partially generated with various Ruby scripts) and also try to dig up the previous cmake efforts, if I decide not to go the applink route.

And, of course, if there are others out there who are interested in this and would like to help, then that might influence which approach I take.

Thanks for all the info!

--Patrick
	cd test
	"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\nmake.exe" /F Makefile.nmake
	cl /I.. /I../WIN32-Code /I../include /I../compat /DHAVE_CONFIG_H /DTINYTEST_LOCAL /Ox /W3 /wd4996 /nologo ..\libevent.lib ws2_32.lib shell32.lib advapi32.lib regress.obj regress_buffer.obj regress_http.obj regress_dns.obj  regress_testutils.obj  regress_rpc.obj regress.gen.obj  regress_et.obj regress_bufferevent.obj  regress_listener.obj regress_util.obj tinytest.obj  regress_main.obj regress_minheap.obj regress_iocp.obj  regress_thread.obj
regress_thread.obj : error LNK2001: unresolved external symbol _evutil_gettimeofday
libevent.lib(event.obj) : error LNK2001: unresolved external symbol _evutil_gettimeofday
libevent.lib(evutil.obj) : error LNK2001: unresolved external symbol _evutil_gettimeofday
regress.obj : error LNK2019: unresolved external symbol _evutil_gettimeofday referenced in function _timeout_cb
regress_http.obj : error LNK2001: unresolved external symbol _evutil_gettimeofday
regress_bufferevent.obj : error LNK2001: unresolved external symbol _evutil_gettimeofday
regress_util.obj : error LNK2001: unresolved external symbol _evutil_gettimeofday
regress.obj : error LNK2019: unresolved external symbol _evutil_usleep_ referenced in function _test_persistent_timeout_jump
regress_util.obj : error LNK2001: unresolved external symbol _evutil_usleep_
regress_thread.obj : error LNK2001: unresolved external symbol _evutil_usleep_
regress_util.obj : error LNK2019: unresolved external symbol _evutil_gettime_monotonic_ referenced in function _test_evutil_monotonic
libevent.lib(event.obj) : error LNK2001: unresolved external symbol _evutil_gettime_monotonic_
regress_util.obj : error LNK2019: unresolved external symbol _evutil_configure_monotonic_time_ referenced in function _test_evutil_monotonic
libevent.lib(event.obj) : error LNK2001: unresolved external symbol _evutil_configure_monotonic_time_
libevent.lib(evthread_win32.obj) : error LNK2019: unresolved external symbol _evutil_tv_to_msec_ referenced in function _evthread_win32_cond_wait
libevent.lib(win32select.obj) : error LNK2001: unresolved external symbol _evutil_tv_to_msec_
regress.exe : fatal error LNK1120: 5 unresolved externals