Difference between revisions of "Compiling libprotobuf"

From AlliedModders Wiki
Jump to: navigation, search
 
(2 intermediate revisions by one other user not shown)
Line 2: Line 2:
  
 
''For Dota 2, replace version 2.5.0 with 2.6.1.''
 
''For Dota 2, replace version 2.5.0 with 2.6.1.''
 
''Also note that the Protobuf source has moved to [http://www.github.com/google/protobuf GitHub]. Some of the below links may be outdated.''
 
  
 
==Windows==
 
==Windows==
 
The following was tested on Windows 8.1 with Visual Studio 2013. Not all projects built after conversion, but only libprotobuf and dependencies were necessary.
 
The following was tested on Windows 8.1 with Visual Studio 2013. Not all projects built after conversion, but only libprotobuf and dependencies were necessary.
  
* Download protobuf-2.5.0.zip from https://code.google.com/p/protobuf/downloads/list
+
* Download protobuf-2.5.0.zip from https://github.com/google/protobuf/releases
 
* Extract and navigate to protobuf-2.5.0/vsprojects/
 
* Extract and navigate to protobuf-2.5.0/vsprojects/
 
* Open protobuf.sln in the version of Visual Studio corresponding with the VC abi version that you wish to compile for.
 
* Open protobuf.sln in the version of Visual Studio corresponding with the VC abi version that you wish to compile for.
Line 24: Line 22:
  
 
<pre>
 
<pre>
wget https://protobuf.googlecode.com/files/protobuf-2.5.0.tar.gz
+
wget https://github.com/google/protobuf/releases/download/v2.5.0/protobuf-2.5.0.tar.gz
 
tar -xvzf protobuf-2.5.0.tar.gz
 
tar -xvzf protobuf-2.5.0.tar.gz
 
cd protobuf-2.5.0
 
cd protobuf-2.5.0
Line 44: Line 42:
  
 
<pre>
 
<pre>
wget https://protobuf.googlecode.com/files/protobuf-2.5.0.tar.gz
+
wget https://github.com/google/protobuf/releases/download/v2.5.0/protobuf-2.5.0.tar.gz
 
tar -xvzf protobuf-2.5.0.tar.gz
 
tar -xvzf protobuf-2.5.0.tar.gz
 
cd protobuf-2.5.0
 
cd protobuf-2.5.0
Line 64: Line 62:
  
 
<pre>
 
<pre>
wget https://protobuf.googlecode.com/files/protobuf-2.5.0.tar.gz
+
wget https://github.com/google/protobuf/releases/download/v2.5.0/protobuf-2.5.0.tar.gz
 
tar -xvzf protobuf-2.5.0.tar.gz
 
tar -xvzf protobuf-2.5.0.tar.gz
 
cd protobuf-2.5.0
 
cd protobuf-2.5.0

Latest revision as of 16:50, 15 April 2016

Examples for compiling a 32-bit libprotobuf and other protobuf libraries using the protobuf-2.5.0 source.

For Dota 2, replace version 2.5.0 with 2.6.1.

Windows

The following was tested on Windows 8.1 with Visual Studio 2013. Not all projects built after conversion, but only libprotobuf and dependencies were necessary.

  • Download protobuf-2.5.0.zip from https://github.com/google/protobuf/releases
  • Extract and navigate to protobuf-2.5.0/vsprojects/
  • Open protobuf.sln in the version of Visual Studio corresponding with the VC abi version that you wish to compile for.
  • Walk through project conversion steps if necessary.
  • Right-click the libprotobuf project and choose properties.
  • In Configuration Properties > C/C++ -> Code Generation, set Runtime Library to /MT for Release or /MTd for Debug.
  • If building the Debug configuration, also add _ITERATOR_DEBUG_LEVEL=0 in Configuration Properties > C/C++ > Preprocessor > Preprocessor Defintions
  • Right-click the libprotobuf project and choose Build.

libprotobuf.lib will be in Release/ or Debug/, depending on build configuration.


Linux (32-bit host)

The following was tested on Debian 6 (Lenny) 32-bit.

wget https://github.com/google/protobuf/releases/download/v2.5.0/protobuf-2.5.0.tar.gz
tar -xvzf protobuf-2.5.0.tar.gz
cd protobuf-2.5.0
./configure
make

For a debug build, replace ./configure with:

./configure CXXFLAGS="-g3 -ggdb3"

This will also override protobuf's default CXXFLAGS of -DNDEBUG

The library will be in src/.libs/


Linux (64-bit host)

This hasn't been tested, but should work on most or all 64-bit distributions.

wget https://github.com/google/protobuf/releases/download/v2.5.0/protobuf-2.5.0.tar.gz
tar -xvzf protobuf-2.5.0.tar.gz
cd protobuf-2.5.0
./configure --build=i686-pc-linux-gnu CFLAGS="-m32 -DNDEBUG" CXXFLAGS="-m32 -DNDEBUG" LDFLAGS=-m32
make

For a debug build, replace ./configure with:

./configure --build=i686-pc-linux-gnu CFLAGS="-m32" CXXFLAGS="-m32 -g3 -ggdb3" LDFLAGS=-m32

This will also override protobuf's default CXXFLAGS of -DNDEBUG

The library will be in src/.libs/


Mac

The following was tested on OS X 10.7 (Lion) and ensures that the outputted binaries are 32-bit.

wget https://github.com/google/protobuf/releases/download/v2.5.0/protobuf-2.5.0.tar.gz
tar -xvzf protobuf-2.5.0.tar.gz
cd protobuf-2.5.0
./configure --build=x86-apple-darwin ABI=standard CFLAGS="-DNDEBUG -m32" CXXFLAGS="-m32 -DNDEBUG" LDFLAGS=-m32
make

For a debug build, replace ./configure with:

./configure --build=x86-apple-darwin ABI=standard CFLAGS="-m32" CXXFLAGS="-m32 -g3 -ggdb3" LDFLAGS=-m32

This will also override protobuf's default CXXFLAGS of -DNDEBUG

The library will be in src/.libs/