-
Notifications
You must be signed in to change notification settings - Fork 199
Install
Fruit's only dependency is on the Boost hashset/hashmap implementation. Even that is optional: you can switch to the
STL implementation by passing the flag -DFRUIT_USES_BOOST=False
to CMake. In any case, the Boost library is only
required when building Fruit itself and not when building code that uses Fruit.
Also, Fruit uses many C++11 features so you need to use a relatively recent compiler in C++11 mode (or later). This is not just to build Fruit itself, but also to build any code that uses Fruit.
The supported compiler/STL/OS combinations are:
- GCC 5.0.0 or later on Linux and OS X
- MinGW's GCC 5.0.0 or later on Windows
- Clang 3.5 or later using stdlibc++ (GCC's STL) on Linux
- Clang 3.5 or later using libc++ on Linux and OS X
- MSVC 2015 or later on Windows
That said, any C++11-compliant compiler should work on any platform.
Compilers known not to work due to a lacking C++11 support and/or compiler bugs:
If you find any other compiler/platform where Fruit doesn't work, feel free to contact me and I can take a look.
Prebuilt packages for Fedora, openSUSE, Ubuntu, Debian and various other distributions are available. These packages are built using GCC, and they will also work with any recent version of Clang.
They may not work with other compilers, or with non-default compile options though. In that case, see the section below on how to compile Fruit manually.
Choose your distribution here (add the repository or use the one-click install if available; don't download individual deb/rpm files since Fruit is split in 2 packages in most distributions)
Then you can compile code using Fruit by:
- Adding
target_link_libraries(your_binary_name fruit)
to yourCMakeLists.txt
file (if you use CMake) - Adding
-lfruit
to your clang++/g++ invocation (otherwise)
I will write packages or build files for other distributions on request. Or if you write one, please send it to me and I will publish it here.
In most cases you can (and should) use the prebuilt packages instead, see the previous section.
For building Fruit, you'll need to have cmake
and make
installed, together with a recent version of GCC/Clang (see
above).
First, get the code from Github: https://github.com/google/fruit/releases
To configure and build:
cmake -DCMAKE_BUILD_TYPE=Release . && make -j
Or if you don't want to use Boost:
cmake -DCMAKE_BUILD_TYPE=Release -DFRUIT_USES_BOOST=False . && make -j
To install (under Linux this uses /usr/local
):
sudo make install
To configure for installation in a specific directory, e.g. /usr
:
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr . && make -j
The above instructions are the simplest to get started, but out-of-source builds are also supported.
Example commands to configure and build:
cmake -DCMAKE_BUILD_TYPE=Release -DBOOST_DIR=C:\boost\boost_1_62_0 .
msbuild ALL_BUILD.vcxproj
Or if you don't want to use Boost:
cmake -DCMAKE_BUILD_TYPE=Release -DFRUIT_USES_BOOST=False .
msbuild ALL_BUILD.vcxproj
The above instructions are the simplest to get started, but out-of-source builds are also supported.
You can import Fruit in Visual Studio (2017 and later) as a CMake project. You need to set the relevant CMake flags in
the CMakeSettings.json
file that Visual Studio will create.
For example, if you installed Boost in C:\boost\boost_1_62_0
, you can put this configuration in your
CMakeSettings.json
:
{
"configurations": [
{
"name": "x64-Release",
"generator": "Visual Studio 15 2017 Win64",
"configurationType": "Release",
"buildRoot": "${env.LOCALAPPDATA}\\CMakeBuild\\${workspaceHash}\\build\\${name}",
"cmakeCommandArgs": "-DBOOST_DIR=C:\\boost\\boost_1_62_0 -DCMAKE_BUILD_TYPE=Release",
"buildCommandArgs": "-m -v:minimal"
}
]
}
Or if you don't want to use Boost, you can use:
{
"configurations": [
{
"name": "x64-Release",
"generator": "Visual Studio 15 2017 Win64",
"configurationType": "Release",
"buildRoot": "${env.LOCALAPPDATA}\\CMakeBuild\\${workspaceHash}\\build\\${name}",
"cmakeCommandArgs": "-DFRUIT_USES_BOOST=False -DCMAKE_BUILD_TYPE=Release",
"buildCommandArgs": "-m -v:minimal"
}
]
}
You can now run CMake within Visual Studio (from the menu: CMake -> Cache -> Generate -> CMakeLists.txt) and build Fruit (from the menu: CMake -> Build All).
For more information (e.g. how to run Fruit tests in MSVC) see the CONTRIBUTING.md file.
Building with Bazel is also supported. You should import the fruit/extras/bazel_root
directory,
not the Fruit root. See the CONTRIBUTING.md file
for more details.
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
vcpkg install fruit
The vcpkg configuration is maintained by Microsoft and other contributors, but not by the maintainers of Fruit. If the version is out of date, please create an issue or pull request on the vcpkg repository, not in Fruit itself.