Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I compile libh2o under windows #1304

Open
wujunjenny opened this issue May 18, 2017 · 8 comments
Open

Can I compile libh2o under windows #1304

wujunjenny opened this issue May 18, 2017 · 8 comments

Comments

@wujunjenny
Copy link

No description provided.

@INRIX-joel-winarske
Copy link
Contributor

There is a fair amount of work involved to port it cleanly to native WIN32. I spent a few afternoons on it to get a feel for it. That said I believe it builds in Cygwin...

@wujunjenny
Copy link
Author

I try to complie libh2o using mingw. but gnulib-tool can't support cmake.I failed to import <sys/socket.h> ... to the project under windows.

@jwinarske
Copy link
Contributor

I just built libh2o via CYGWIN. There is only a minor change required:

$  cmake . -G"Unix Makefiles" -DWITH_BUNDLED_SSL=0 -DWITH_MRUBY=0 -DLIBUV_LIBRARIES=~/git/libuv/.libs/libuv.a -DLIBUV_INCLUDE_DIR=~/git/libuv/include -DLIBUV_VERSION=1.11.0
$ make examples-simple
$ git diff
diff --git a/deps/libyrmcds/yrmcds_portability.h b/deps/libyrmcds/yrmcds_portability.h
index c9fd4d91..b1f151d4 100644
--- a/deps/libyrmcds/yrmcds_portability.h
+++ b/deps/libyrmcds/yrmcds_portability.h
@@ -27,7 +27,7 @@
 #  define htole64(x) OSSwapHostToLittleInt64(x)
 #  define be64toh(x) OSSwapBigToHostInt64(x)
 #  define le64toh(x) OSSwapLittleToHostInt64(x)
-#elif defined(__linux__)
+#elif defined(__linux__) || defined (__CYGWIN__)
 #  include <endian.h>
 #elif defined(sun) // Solaris
 #  include <sys/byteorder.h>

@Varbin
Copy link
Contributor

Varbin commented Jun 12, 2017

I tried building the complete server today - it worked. Now I can use h2o on Windows. I think this should be submitted in a pull request.

@locpyl-tidnyd
Copy link

This thread is now more than 3 years old. h2o has changed since then and the current sources no longer build or work as-is on MingW (if they ever did). I made a patch for h2o while porting Urbit to Windows that the h2o project might be interested in. Its scope is limited to what I needed for Urbit: only the libuv variant is built, and no fastcgi or memcached support. The biggest change by line count is caused by libuv uv_buf_t and h2o h2o_iovec_t declaring the two fields in reverse order: on MingW, libuv uses the WinSock order to avoid extra copying, whereas h2o uses the POSIX order. The patch swaps the fields in h2o_iovec_t if built on MingW.

/cc @kazuho

@rcombs
Copy link

rcombs commented May 15, 2021

@locpyl-tidnyd This patch doesn't apply on current h2o; could you rebase on current master and submit it as a pull request?

@jwinarske
Copy link
Contributor

Sure.

@locpyl-tidnyd
Copy link

That was rather more work than I expected, but here it is: #2720 It shouldn't break anything outside MingW or require extra effort maintaining it beyond using the new H2O_IOVEC_XXX macros and h2o_iovec_init(base, len) instead of (h2o_iovec_t){base, len}, but it's not battle-tested by any means. I contribute it in the hope that somebody else will find it useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants