Build protobuf on Windows with MinGW

2019-04-12 12:24发布

问题:

I have been following the steps in Peter's answer to How to build Google's protobuf in Windows using MinGW? but make does not complete and errors out.


I am on Win64 and have MinGW with installed the mingw-developer-toolkit, mingw32-base, mingw-gcc-g++, msys-base and additionally mingw32-phtreads-w32.

Under MinGW/msys/1.0 I create the folder /home/<username> and paste the protobuf-3.1.0 source downloaded from github.

I open an MSYS shell, cd into the protobuf dir and run ./autoconfig: the log is here.

Now, the first thing I don't like from the log is:

configure:16556: checking for the pthreads library -lpthreads
configure:16589: gcc -o conftest.exe     conftest.c -lpthreads -lz  >&5
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../../mingw32/bin/ld.exe: cannot find -lpthreads

Why is it not finding pthreads when I have it installed?

Then, I proceed with make and get protoc.exe has stopped working with the following crash info:

  Problem signature:
  Problem Event Name:   APPCRASH
  Application Name: protoc.exe
  Application Version:  0.0.0.0
  Application Timestamp:    580a23df
  Fault Module Name:    libprotobuf-11.dll
  Fault Module Version: 0.0.0.0
  Fault Module Timestamp:   580a225f
  Exception Code:   c0000005
  Exception Offset: 001171cd
  OS Version:   6.1.7601.2.1.0.256.4
  Locale ID:    2057
  Additional Information 1: 4c0d
  Additional Information 2: 4c0d4d78887f76d971d5d00f1f20a433
  Additional Information 3: 4c0d
  Additional Information 4: 4c0d4d78887f76d971d5d00f1f20a433

and the shell ends with

make[2]: *** [unittest_proto_middleman] Error 5
make[2]: Leaving directory `/home/ok1011/protobuf-3.1.0/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/ok1011/protobuf-3.1.0'
make: *** [all] Error 2

Here you can find the make log and error. I am not the only one having this issue.

Any ideas what might be the problem and how to fix it?