Windows users
=============

## Build protobuf from source (Only for RProtoBufLib package maintainers)


#### build it with MSYS2 shipped with rtools4.0
1. Rtools (4.0)
2. open MSYS2 MINGW32 shell launcher(i.e. c:\rtools40\mingw32.exe) so that all the nix tools are available for building script
3. mkdir 32 && cd 32 && ../protobuf_src_folder/configure --prefix=./32/install && make install
4. open MSYS2 MINGW64 shell launcher(i.e. c:\rtools40\mingw64.exe)
5. build 64 bit lib similar to 3)

#### build it with MYSYS1.0 + mingw
1. Rtools (3.x)
2. install MSYS-1.0.11
3. point it to the mingw_32(by mounting mingw_32 to /mingw in fstab file) installed by Rtools
4. open MYSYS terminal (so that all the nix tools are available for building script)
5. mkdir 32 && cd 32 && ../protobuf_src_folder/configure --prefix=./32/install && make install
6. mounting mingw_64 to /mingw in fstab file
7. build 64 bit lib similar to 5)

## cross-compiling protobuf 

It is now not working due to the incompatible exception model used by mingw on linux (sjlj) 
vs Rtools (dwarf). Unless manually build mingw from src with --disable-sjlj and --enable-dwarf

1. install cross-compiling tool chain on linux
(and With mingw there are two different threading models: posix and win32. need to use posix
 e.g. update-alternatives --config x86_64-w64-mingw32-g++)
2. download the source
2. first install protobuf on local linux (so that 'protoc' command is available for cross compiling later on
3. the run configure script for win64:
configure --host=x86_64-w64-mingw32 --prefix=/your_path/protobuf/x64 --enable-shared=no --with-protoc=protoc LDFLAGS='-static-libgcc' CXXFLAGS=-DHAVE_PTHREAD=1
4. then run make and make install
5. for win32: (need manually cp the .a file due to the error of target libprotoc
configure --host=i686-w64-mingw32 --prefix=/your_path/protobuf/i386 --enable-shared=no --with-protoc=protoc LDFLAGS='-static-libgcc' CXXFLAGS=-DHAVE_PTHREAD=1