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