install.md (5822B)
1 --- 2 layout: page 3 title: Installation 4 --- 5 6 # Installation: Tools and C++ Runtime 7 8 <div style="float: right"><a class="groups_link" style="color: #fff" 9 href="https://groups.google.com/group/capnproto-announce">Get Notified of Updates</a></div> 10 11 The Cap'n Proto tools, including the compiler (which takes `.capnp` files and generates source code 12 for them), are written in C++. Therefore, you must install the C++ package even if your actual 13 development language is something else. 14 15 This package is licensed under the [MIT License](http://opensource.org/licenses/MIT). 16 17 ## Prerequisites 18 19 ### Supported Compilers 20 21 Cap'n Proto makes extensive use of C++14 language features. As a result, it requires a relatively 22 new version of a well-supported compiler. The minimum versions are: 23 24 * GCC 5.0 25 * Clang 5.0 26 * Visual C++ 2017 27 28 If your system's default compiler is older that the above, you will need to install a newer 29 compiler and set the `CXX` environment variable before trying to build Cap'n Proto. For example, 30 after installing GCC 5, you could set `CXX=g++-5` to use this compiler. 31 32 ### Supported Operating Systems 33 34 In theory, Cap'n Proto should work on any POSIX platform supporting one of the above compilers, 35 as well as on Windows. We test every Cap'n Proto release on the following platforms: 36 37 * Android 38 * Linux 39 * Mac OS X 40 * Windows - Cygwin 41 * Windows - MinGW-w64 42 * Windows - Visual C++ 43 44 **Windows users:** Cap'n Proto requires Visual Studio 2017 or newer. All features 45 of Cap'n Proto -- including serialization, dynamic API, RPC, and schema parser -- are now supported. 46 47 **Mac OS X users:** You should use the latest Xcode with the Xcode command-line 48 tools (Xcode menu > Preferences > Downloads). Alternatively, the command-line tools 49 package from [Apple](https://developer.apple.com/downloads/) or compiler builds from 50 [Macports](http://www.macports.org/), [Fink](http://www.finkproject.org/), or 51 [Homebrew](http://brew.sh/) are reported to work. 52 53 ## Installation: Unix 54 55 **From Release Tarball** 56 57 You may download and install the release version of Cap'n Proto like so: 58 59 <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> 60 tar zxf capnproto-c++-0.0.0.tar.gz 61 cd capnproto-c++-0.0.0 62 ./configure 63 make -j6 check 64 sudo make install</code></pre> 65 66 This will install `capnp`, the Cap'n Proto command-line tool. It will also install `libcapnp`, 67 `libcapnpc`, and `libkj` in `/usr/local/lib` and headers in `/usr/local/include/capnp` and 68 `/usr/local/include/kj`. 69 70 **From Package Managers** 71 72 Some package managers include Cap'n Proto packages. 73 74 Note: These packages are not maintained by us and are sometimes not up to date with the latest Cap'n Proto release. 75 76 * Debian / Ubuntu: `apt-get install capnproto` 77 * Arch Linux: `sudo pacman -S capnproto` 78 * Homebrew (OSX): `brew install capnp` 79 80 **From Git** 81 82 If you download directly from Git, you will need to have the GNU autotools -- 83 [autoconf](http://www.gnu.org/software/autoconf/), 84 [automake](http://www.gnu.org/software/automake/), and 85 [libtool](http://www.gnu.org/software/libtool/) -- installed. 86 87 git clone https://github.com/sandstorm-io/capnproto.git 88 cd capnproto/c++ 89 autoreconf -i 90 ./configure 91 make -j6 check 92 sudo make install 93 94 ## Installation: Windows 95 96 **From Release Zip** 97 98 1. Download Cap'n Proto Win32 build: 99 100 <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> 101 102 2. Find `capnp.exe`, `capnpc-c++.exe`, and `capnpc-capnp.exe` under `capnproto-tools-win32-0.0.0` in 103 the zip and copy them somewhere. 104 105 3. If your `.capnp` files will import any of the `.capnp` files provided by the core project, or 106 if you use the `stream` keyword (which implicitly imports `capnp/stream.capnp`), then you need 107 to put those files somewhere where the capnp compiler can find them. To do this, copy the 108 directory `capnproto-c++-0.0.0/src` to the location of your choice, then make sure to pass the 109 flag `-I <that location>` to `capnp` when you run it. 110 111 If you don't care about C++ support, you can stop here. The compiler exe can be used with plugins 112 provided by projects implementing Cap'n Proto in other languages. 113 114 If you want to use Cap'n Proto in C++ with Visual Studio, do the following: 115 116 1. Make sure that you are using Visual Studio 2017 or newer, with all updates installed. Cap'n 117 Proto uses C++14 language features that did not work in previous versions of Visual Studio, 118 and the updates include many bug fixes that Cap'n Proto requires. 119 120 2. Install [CMake](http://www.cmake.org/) version 3.1 or later. 121 122 3. Use CMake to generate Visual Studio project files under `capnproto-c++-0.0.0` in the zip file. 123 You can use the CMake UI for this or run this shell command: 124 125 cmake -G "Visual Studio 15 2017" 126 127 3. Open the "Cap'n Proto" solution in Visual Studio. 128 129 4. Adjust the project build options (e.g., choice of C++ runtime library, enable/disable exceptions 130 and RTTI) to match the options of the project in which you plan to use Cap'n Proto. 131 132 5. Build the solution (`ALL_BUILD`). 133 134 6. Build the `INSTALL` project to copy the compiled libraries, tools, and header files into 135 `CMAKE_INSTALL_PREFIX`. 136 137 Alternatively, find the compiled `.lib` files in the build directory under 138 `src/{capnp,kj}/{Debug,Release}` and place them somewhere where your project can link against them. 139 Also add the `src` directory to your search path for `#include`s, or copy all the headers to your 140 project's include directory. 141 142 Cap'n Proto can also be built with MinGW or Cygwin, using the Unix/autotools build instructions. 143 144 **From Git** 145 146 The C++ sources are located under `c++` directory in the git repository. The build instructions are 147 otherwise the same as for the release zip. 148