Yellow-Camper / libevhtp

Create extremely-fast and secure embedded HTTP servers with ease.
https://criticalstack.com/
BSD 3-Clause "New" or "Revised" License
428 stars 162 forks source link

Building libevhtp on windows. #103

Open Elunyfay opened 6 years ago

Elunyfay commented 6 years ago

Greetings! I've been trying to build libevhtp for some 2 monthes time to time, already told about this in libevent issue thread https://github.com/libevent/libevent/issues/634 so I will write finally as you asked (thank you anyway!). It was easy with linux (just followed readme). We want to have crossplatform program with your library so I have to do it in windows. I'm beginner in cmake and tryed to do everything myself, but no good result.

So: building in windows 8 with MinGW of different versions (4.8.3 and 5.3 at start, now fresh 8.1 only. For example nuwen version https://nuwen.net/mingw.html) with CMake (cmake-gui.exe mostly), also I've downloaded oniguruma, jemalloc without cmake and jemalloc-cmake (because cmake asks for directory with FindJemalloc.cmake. No once it didn't work). I'm trying to do minimal build so disabling everything I can. Cmake-gui still asked for jemalloc ever after setting "EVHTP_DISABLE_MEMFUNCTION" flag. Some fields are not clear for me still (what exactly to set in LIBEVENT_SSL, LIBEVENT_THREAD? I've found only libssl.lib from openssl and libwinpthread.dll from mingw there. Readme talks about using pthread. MinGW installation contains one).

Earlyer I had errors of CMake creating building sub-directory, faulting with something like "file not found" with "gcc check - broken" result, that's solved after deleting everything (mingw, cygwin, strawberryPerl that has own gcc inside, etc...) and installing only one good build of mingw.

At last days I'm getting successfull messages in cmake-gui (configuration and generation done), but there is nothing in build directory (I've named them libevhtp/mycmakebuild for GUI builds, so libevhtp/build is filled by console cmake tryes only). So I've thought that I need to do make and run mingw32-make.exe in console (from mingw-cmd, from msys...) and it results in error "[25%] Building C Object CMakeFiles/evhtp.dir/evhtp.c.obj cc1.exe error: CPU you selected does not support x86-64 instruction set] Error 1, [Makefile:151 all] Error 2". I've checked - every used library and program is 64bit, flags -march in gcc set to "nocone" that must not result in "i686" or any 32bit.

Simple running cmake -G "MinGW" with -DCMAKE_mingw dependencies results in same questions as in cmake-gui at configure-button, so I've used GUI.

Archive with project and all my libraries I've hosted here - https://drive.google.com/open?id=1uxqdCf0-kKvSE3CLEh3Ke9q_LHFdSw-G Here you can look at CMakeCache.txt with used configurations and all you need.

My collegue has done building somehow with cygwin with -G "Unix Makefiles" flag on his windows machine, but it resulted in arch-linux library. No idea how to set right target system.

I'm happy to learn by the way, if difficulty gives to understand. Thank you!

NathanFrench commented 6 years ago

Sounds like you're going through quite the hellish time. I'll have to get a windows license, which shouldn't be a problem. I'll get back to you asap.

Elunyfay commented 6 years ago

I'm in no hurry for now, tomorrow going to month vacation)

Elunyfay commented 6 years ago

I think I found reason for 32/64 bit error. It's set i486 in CMakeLists.txt:

if(WIN32)
    target_compile_definitions(evhtp PUBLIC WIN32)
    target_compile_options(evhtp PUBLIC -march=i486)
    find_library(LIB_WS32 ws2_32)
    list(APPEND SYS_LIBS ${LIB_WS32})
endif()

There must be some switch to 32 and 64 branches? Maybe 32 is enough for this lib, but for 64bit program I need 64bit libs also, right?

NathanFrench commented 6 years ago

Awesome, I'm still waiting on a windows license. Please submit pull requests as you go along; I want you to get credit for your hard work.