Compiling in windows using mingw-w64?

1,001 views
Skip to first unread message

Alexandros Karypidis

unread,
May 10, 2015, 3:41:23 PM5/10/15
to capn...@googlegroups.com
Hi,

I've just tried compiling the sources on a windows host using mingw-w64. Specifically:

- my host and target are 64-bit
- I used the x64-4.8.1-release-win32-seh-rev5 binaries (structured exception handling with native windows threads)
- autoreconf was from the msys binaries

I basically ran "autoreconf -i" followed by "./configure" in the c++ folder. Then during "make" the build stopped at:

libtool: compile:  g++ -std=gnu++11 -DHAVE_CONFIG_H -I. -I./src -I./src -DKJ_HEADER_WARNINGS -DCAPNP_HEADER_WARNINGS -DCAPNP_INCLUDE_DIR=\"/usr/local/include\" -mthreads -O2 -DNDEBUG -mthreads -MT src/kj/exception.lo -MD -MP -MF src/kj/.deps/exception.Tpo -c src/kj/exception.c++  -DDLL_EXPORT -DPIC -o src/kj/.libs/exception.o
src/kj/exception.c++:31:22: fatal error: sys/mman.h: No such file or directory
 #include <sys/mman.h>
                      ^

I was wondering if it is at all possible to build with mingw under windows. This missing header seems to indicate mingw does not support some memory mapping/protection API? Anyway, I just commented out the include to see what happens and the build failed at:

libtool: compile:  g++ -std=gnu++11 -DHAVE_CONFIG_H -I. -I./src -I./src -DKJ_HEADER_WARNINGS -DCAPNP_HEADER_WARNINGS -DC
APNP_INCLUDE_DIR=\"/usr/local/include\" -mthreads -O2 -DNDEBUG -mthreads -MT src/kj/exception.lo -MD -MP -MF src/kj/.dep
s/exception.Tpo -c src/kj/exception.c++  -DDLL_EXPORT -DPIC -o src/kj/.libs/exception.o
src/kj/exception.c++:152:30: error: 'siginfo_t' has not been declared
 void crashHandler(int signo, siginfo_t* info, void* context) {

Not sure if that header was related to signal processing, but looking at the code I saw that it was just a constructing a message with information about the signal received, and it was actually only using signo and not touching the siginfo_t info pointer. So I thought I'd persist and changed the declaration to (siginfo_t* to void*):

void crashHandler(int signo, void* info, void* context) {

I also changed the call to strsignal to a fixed message since I can live without it, like this:

auto message = kj::str("*** Received signal #", signo, ": ", "strsignal(signo) n/a in mingw",

...and compilation proceeded to "sort of succeed". It failed at:

echo capnp.exe capnpc-c++.exe src/capnp/test.capnp src/capnp/test-import.capnp src/capnp/test-import2.capnp | (read CAPN
P CAPNPC_CXX SOURCES && ./$CAPNP compile --src-prefix=./src -o./$CAPNPC_CXX:src -I./src $SOURCES)
plugin:./.libs/lt-capnpc-c++.c:239: FATAL: couldn't find plugin.
*** Uncaught exception ***
kj/io.c++:276: disconnected: miniposix::write(fd, pos, size): Broken pipe; fd = 4
Makefile:2897: recipe for target `test_capnpc_middleman' failed
make: *** [test_capnpc_middleman] Error 1

As far as I can tell:

- I managed to build capnp.exe. It exists and I can run it.
- For some reason when the build tried to use capnp.exe to process a test.capnp it failed due to some plugin missing

Now, I've never used capnp, it's my first experience with it. I also normally steer away from windows in my work so I only installed MinGW in order to do this build (I use it for nothing else, it's just that I feel much more comfortable with a gcc compiler than visual studio so it would be easier for me). As you might expect my questions are quite basic as I'm a absolute newbie:

1) Is anyone compiling capnp with mingw on windows? Is it supposed to work?
2) Why does my build fail to run that capnp command? What plugin is missing? Is it something that ./configure caused to be left out? I didn't specify any options when configuring, just the defaults.
3) The changes needed to produce the binary seem quite minimal. Would you be interested in a more appropriate patch to get it to work out of the box?

Thanks!

Kenton Varda

unread,
May 10, 2015, 8:39:15 PM5/10/15
to Alexandros Karypidis, capnproto
Hi Alexandros,

We support Cap'n Proto on MinGW in lite mode (no RPC or dynamic API) and for building the compiler itself (this is how we built the binaries in the win32 package).

However, it looks like you are trying to build the source from git master rather than a release version. Between releases, we make no attempt to keep Cap'n Proto working across all supported platforms, and the more-obscure ones (like MinGW) tend to break. We've added a bunch of new code in the 0.6 branch which will need to be ported to Win32 and we haven't done that yet.

If you want to build on MinGW, you'll need to work from release 0.5.2. In fact, we recommend always building from the release version on every platform, unless you are working directly on Cap'n Proto or Sandstorm.io.

When building 0.5.2, if you want to build the executables, you'll need to configure Cap'n Proto regularly and then build *specifically* the capnp.exe and capnpc-cpp.exe make targets (if you try to compile everything, it won't work). Once you have the compiler binaries, you'll want to reconfigure with --disable-reflection, i.e. in "lite mode", and then you'll be able to build the libraries and tests. That is:

    # make the compiler
    ./configure --disable-shared
    make capnp.exe capnpc-cpp.exe
    cp *.exe /somewhere/in/path

    # make the libraries
    make distclean
    ./configure --disable-reflection --with-external-capnp
    make check

This is somewhat convoluted currently. We hope to improve Windows support in future versions.

(BTW, the error you got about plugins missing is because you hadn't built capnpc-cpp.exe, the C++ code generator plugin.)

-Kenton

--
You received this message because you are subscribed to the Google Groups "Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+...@googlegroups.com.
Visit this group at http://groups.google.com/group/capnproto.

Alexandros Karypidis

unread,
May 12, 2015, 5:54:33 AM5/12/15
to capn...@googlegroups.com, kar...@gmail.com
Hi,

Indeed it seems like most of my woes were due to me going all gung-ho on this and using master. I followed your instructions and everything "just works". Thank you!

Some notes:

- In Kenton's instructions the compiler-build's second make target is actually "capnpc-c++.exe"
- If you use a git clone and branch "release-0.5.2", you also need to manually download the googletest framework for the tests to be built (make check step). This is included in the source distribution by the way...

Kenton Varda

unread,
May 13, 2015, 9:50:52 PM5/13/15
to Alexandros Karypidis, capnproto
On Tue, May 12, 2015 at 2:54 AM, Alexandros Karypidis <kar...@gmail.com> wrote:
- In Kenton's instructions the compiler-build's second make target is actually "capnpc-c++.exe"

Oops, yes.
 
- If you use a git clone and branch "release-0.5.2", you also need to manually download the googletest framework for the tests to be built (make check step). This is included in the source distribution by the way...

The `setup-autotools.sh` script does this; this is mentioned in the installation instructions under "from git".

FWIW, the gtest dependency will go away in 0.6.0.

-Kenton
Reply all
Reply to author
Forward
0 new messages