cannam@48
|
1 ---
|
cannam@48
|
2 layout: page
|
cannam@48
|
3 title: Installation
|
cannam@48
|
4 ---
|
cannam@48
|
5
|
cannam@48
|
6 # Installation: Tools and C++ Runtime
|
cannam@48
|
7
|
cannam@48
|
8 The Cap'n Proto tools, including the compiler (which takes `.capnp` files and generates source code
|
cannam@48
|
9 for them), are written in C++. Therefore, you must install the C++ package even if your actual
|
cannam@48
|
10 development language is something else.
|
cannam@48
|
11
|
cannam@48
|
12 This package is licensed under the [MIT License](http://opensource.org/licenses/MIT).
|
cannam@48
|
13
|
cannam@48
|
14 ## Caveats
|
cannam@48
|
15
|
cannam@48
|
16 <p style="font-size: 125%; font-weight: bold;">Cap'n Proto is in BETA</p>
|
cannam@48
|
17
|
cannam@48
|
18 <div style="float: right"><a class="groups_link" style="color: #fff"
|
cannam@48
|
19 href="https://groups.google.com/group/capnproto-announce">Sign Up for Updates</a></div>
|
cannam@48
|
20
|
cannam@48
|
21 As of this writing, Cap'n Proto is in beta. The serialization layer is close to feature-complete
|
cannam@48
|
22 and we don't anticipate any further changes to the wire format. That said, if you want to use it,
|
cannam@48
|
23 you should keep in mind some caveats:
|
cannam@48
|
24
|
cannam@48
|
25 * **Security:** Cap'n Proto has not yet had a security review. Although Kenton has a background
|
cannam@48
|
26 in security and is not aware of any vulnerabilities in the current code, it's likely that there
|
cannam@48
|
27 are a few, and [some have been found](https://github.com/sandstorm-io/capnproto/tree/master/security-advisories)
|
cannam@48
|
28 in the past. For now, do not accept Cap'n Proto messages from parties you do not trust.
|
cannam@48
|
29 * **API Stability:** The Cap'n Proto programming interface may still change in ways that break
|
cannam@48
|
30 existing code. Such changes are likely to be minor and should not affect the wire format.
|
cannam@48
|
31 * **Performance:** While Cap'n Proto is inherently fast by design, the implementation has not yet
|
cannam@48
|
32 undergone serious profiling and optimization. Currently it only beats Protobufs in realistic-ish
|
cannam@48
|
33 end-to-end benchmarks by around 2x-5x. We can do better.
|
cannam@48
|
34 * **RPC:** The RPC implementation particularly experimental, though it is used heavily by
|
cannam@48
|
35 [Sandstorm.io](https://sandstorm.io).
|
cannam@48
|
36
|
cannam@48
|
37 If you'd like to hack on Cap'n Proto, you should join the
|
cannam@48
|
38 [discussion group](https://groups.google.com/group/capnproto)!
|
cannam@48
|
39
|
cannam@48
|
40 If you'd just like to receive updates as things progress, add yourself to the
|
cannam@48
|
41 [announce list](https://groups.google.com/group/capnproto-announce).
|
cannam@48
|
42
|
cannam@48
|
43 ## Prerequisites
|
cannam@48
|
44
|
cannam@48
|
45 ### Supported Compilers
|
cannam@48
|
46
|
cannam@48
|
47 Cap'n Proto makes extensive use of C++11 language features. As a result, it requires a relatively
|
cannam@48
|
48 new version of a well-supported compiler. The minimum versions are:
|
cannam@48
|
49
|
cannam@48
|
50 * GCC 4.8
|
cannam@48
|
51 * Clang 3.3
|
cannam@48
|
52 * Visual C++ 2015 (lite mode only)
|
cannam@48
|
53
|
cannam@48
|
54 If your system's default compiler is older that the above, you will need to install a newer
|
cannam@48
|
55 compiler and set the `CXX` environment variable before trying to build Cap'n Proto. For example,
|
cannam@48
|
56 after installing GCC 4.8, you could set `CXX=g++-4.8` to use this compiler.
|
cannam@48
|
57
|
cannam@48
|
58 ### Supported Operating Systems
|
cannam@48
|
59
|
cannam@48
|
60 In theory, Cap'n Proto should work on any POSIX platform supporting one of the above compilers,
|
cannam@48
|
61 as well as on Windows. We test every Cap'n Proto release on the following platforms:
|
cannam@48
|
62
|
cannam@48
|
63 * Android
|
cannam@48
|
64 * Linux
|
cannam@48
|
65 * Mac OS X
|
cannam@48
|
66 * Windows - Cygwin
|
cannam@48
|
67 * Windows - MinGW-w64 (lite mode and compiler binary only)
|
cannam@48
|
68 * Windows - Visual C++ (lite mode only)
|
cannam@48
|
69
|
cannam@48
|
70 **Windows users:** As of Visual Studio 2015, Visual C++ still does not support enough of C++11 to
|
cannam@48
|
71 compile Cap'n Proto's reflection or RPC APIs. "Cap'n Proto Lite" omits these features from the
|
cannam@48
|
72 library, giving you only the core serialization based on generated code.
|
cannam@48
|
73
|
cannam@48
|
74 **Mac OS X users:** You must use at least Xcode 5 with the Xcode command-line
|
cannam@48
|
75 tools (Xcode menu > Preferences > Downloads). Alternatively, the command-line tools
|
cannam@48
|
76 package from [Apple](https://developer.apple.com/downloads/) or compiler builds from
|
cannam@48
|
77 [Macports](http://www.macports.org/), [Fink](http://www.finkproject.org/), or
|
cannam@48
|
78 [Homebrew](http://brew.sh/) are reported to work.
|
cannam@48
|
79
|
cannam@48
|
80 ## Installation: Unix
|
cannam@48
|
81
|
cannam@48
|
82 **From Release Tarball**
|
cannam@48
|
83
|
cannam@48
|
84 You may download and install the release version of Cap'n Proto like so:
|
cannam@48
|
85
|
cannam@48
|
86 <pre><code>curl -O <a href="https://capnproto.org/capnproto-c++-0.0.0.tar.gz">https://capnproto.org/capnproto-c++-0.0.0.tar.gz</a>
|
cannam@48
|
87 tar zxf capnproto-c++-0.0.0.tar.gz
|
cannam@48
|
88 cd capnproto-c++-0.0.0
|
cannam@48
|
89 ./configure
|
cannam@48
|
90 make -j6 check
|
cannam@48
|
91 sudo make install</code></pre>
|
cannam@48
|
92
|
cannam@48
|
93 This will install `capnp`, the Cap'n Proto command-line tool. It will also install `libcapnp`,
|
cannam@48
|
94 `libcapnpc`, and `libkj` in `/usr/local/lib` and headers in `/usr/local/include/capnp` and
|
cannam@48
|
95 `/usr/local/include/kj`.
|
cannam@48
|
96
|
cannam@48
|
97 **From Package Managers**
|
cannam@48
|
98
|
cannam@48
|
99 Some package managers include Cap'n Proto packages.
|
cannam@48
|
100
|
cannam@48
|
101 Note: These packages are not maintained by us and are sometimes not up to date with the latest Cap'n Proto release.
|
cannam@48
|
102
|
cannam@48
|
103 * Debian / Ubuntu: `apt-get install capnproto`
|
cannam@48
|
104 * Homebrew (OSX): `brew install capnp`
|
cannam@48
|
105
|
cannam@48
|
106 **From Git**
|
cannam@48
|
107
|
cannam@48
|
108 If you download directly from Git, you will need to have the GNU autotools --
|
cannam@48
|
109 [autoconf](http://www.gnu.org/software/autoconf/),
|
cannam@48
|
110 [automake](http://www.gnu.org/software/automake/), and
|
cannam@48
|
111 [libtool](http://www.gnu.org/software/libtool/) -- installed.
|
cannam@48
|
112
|
cannam@48
|
113 git clone https://github.com/sandstorm-io/capnproto.git
|
cannam@48
|
114 cd capnproto/c++
|
cannam@48
|
115 autoreconf -i
|
cannam@48
|
116 ./configure
|
cannam@48
|
117 make -j6 check
|
cannam@48
|
118 sudo make install
|
cannam@48
|
119
|
cannam@48
|
120 ## Installation: Windows
|
cannam@48
|
121
|
cannam@48
|
122 **From Release Zip**
|
cannam@48
|
123
|
cannam@48
|
124 1. Download Cap'n Proto Win32 build:
|
cannam@48
|
125
|
cannam@48
|
126 <pre><a href="https://capnproto.org/capnproto-c++-win32-0.0.0.zip">https://capnproto.org/capnproto-c++-win32-0.0.0.zip</a></pre>
|
cannam@48
|
127
|
cannam@48
|
128 2. Find `capnp.exe`, `capnpc-c++.exe`, and `capnpc-capnp.exe` under `capnproto-tools-win32-0.0.0` in
|
cannam@48
|
129 the zip and copy them somewhere.
|
cannam@48
|
130
|
cannam@48
|
131 If you don't care about C++ support, you can stop here. The compiler exe can be used with plugins
|
cannam@48
|
132 provided by projects implementing Cap'n Proto in other languages.
|
cannam@48
|
133
|
cannam@48
|
134 If you want to use Cap'n Proto in C++ with Visual Studio, do the following:
|
cannam@48
|
135
|
cannam@48
|
136 1. Install [CMake](http://www.cmake.org/) version 3.1 or later.
|
cannam@48
|
137
|
cannam@48
|
138 2. Use CMake to generate Visual Studio project files under `capnproto-c++-0.0.0` in the zip file.
|
cannam@48
|
139 You will need to enable the CMake project options `CAPNP_LITE` and `EXTERNAL_CAPNP`.
|
cannam@48
|
140 You can use the CMake UI for this or run this shell command:
|
cannam@48
|
141
|
cannam@48
|
142 cmake -G "Visual Studio 14 2015" -DCAPNP_LITE=1 -DEXTERNAL_CAPNP=1
|
cannam@48
|
143
|
cannam@48
|
144 If the `capnp.exe` and `capnpc-c++.exe` tools are not on your `PATH`, then `CAPNP_EXECUTABLE`
|
cannam@48
|
145 and `CAPNPC_CXX_EXECUTABLE` will need to be set to their respective locations.
|
cannam@48
|
146
|
cannam@48
|
147 3. Open the "Cap'n Proto" solution in Visual Studio.
|
cannam@48
|
148
|
cannam@48
|
149 4. Adjust the project build options (e.g., choice of C++ runtime library, enable/disable exceptions
|
cannam@48
|
150 and RTTI) to match the options of the project in which you plan to use Cap'n Proto.
|
cannam@48
|
151
|
cannam@48
|
152 5. Build the solution (`ALL_BUILD`).
|
cannam@48
|
153
|
cannam@48
|
154 6. Build the `INSTALL` project to copy the compiled libraries and header files into `CMAKE_INSTALL_PREFIX`.
|
cannam@48
|
155
|
cannam@48
|
156 Alternatively, find the compiled `.lib` files in the build directory under
|
cannam@48
|
157 `src/{capnp,kj}/{Debug,Release}` and place them somewhere where your project can link against them.
|
cannam@48
|
158 Also add the `src` directory to your search path for `#include`s, or copy all the headers to your
|
cannam@48
|
159 project's include directory.
|
cannam@48
|
160
|
cannam@48
|
161 7. Add `#define CAPNP_LITE 1` to either your project's precompiled/shared header or compiler options.
|
cannam@48
|
162
|
cannam@48
|
163 **From Git**
|
cannam@48
|
164
|
cannam@48
|
165 If you download directly from Git, you'll need to compile the Cap'n Proto tools (the `.exe`s) using
|
cannam@48
|
166 MinGW-w64. This is easiest to do in Cygwin or on Linux. For example, on Debian or Ubuntu, you can
|
cannam@48
|
167 install MinGW like so:
|
cannam@48
|
168
|
cannam@48
|
169 sudo apt-get install mingw-w64
|
cannam@48
|
170
|
cannam@48
|
171 You'll first need to install Cap'n Proto on the host system (using the Unix installation
|
cannam@48
|
172 instructions, above). Then, do:
|
cannam@48
|
173
|
cannam@48
|
174 make distclean
|
cannam@48
|
175 ./configure --host=i686-w64-mingw32 --with-external-capnp \
|
cannam@48
|
176 --disable-shared CXXFLAGS='-static-libgcc -static-libstdc++'
|
cannam@48
|
177 make -j6 capnp.exe capnpc-c++.exe capnpc-capnp.exe
|
cannam@48
|
178
|
cannam@48
|
179 Now that you have the `exe`s, you can proceed with the usual Windows compilation instructions.
|