The libpmemobj-cpp project will no longer be maintained by Intel.
libpmemobj-cpp is a C++ binding for libpmemobj (a library which is a part of PMDK collection). More implementation details can be found in include/libpmemobj++/README.md.
Latest releases can be found on the "releases" tab. Up-to-date support/maintenance status of branches/releases is available on pmem.io.
In libpmemobj 1.12 we introduced a new transaction handler type: pmem::obj::flat_transaction. By defining LIBPMEMOBJ_CPP_USE_FLAT_TRANSACTION you can make pmem::obj::transaction to be an alias to pmem::obj::flat_transaction. In 1.12 we have also changed the default behavior of containers' transactional methods. Now, in case of any failure within such method, the outer transaction (if any) will not be immediately aborted. Instead, an exception will be thrown, which will lead to transaction abort only if it's not caught before the outer tx scope ends. To change the behavior to the old one, you can set LIBPMEMOBJ_CPP_FLAT_TX_USE_FAILURE_RETURN macro to 0. Be aware that the old behavior can lead to segfaults in some cases (see tx_nested_struct_example in this file).
The best way to install stable releases, tested on specific OS, is to use package manager.
The recommended and the easiest way to install libpmemobj-cpp on Windows is to use Microsoft's vcpkg. Vcpkg is an open source tool and ecosystem created for library management. For more information about vcpkg please see vcpkg repository.
.\vcpkg.exe install libpmemobj-cpp:x64-windows
For installation on Debian-related distros please execute following commands:
# apt install libpmemobj-cpp-dev
To install libpmemobj-cpp on Fedora or RedHat execute:
# dnf install libpmemobj++-devel
You will need the following packages for compilation:
Required packages (or their names) for some OSes may differ. Some examples or scripts in this repository may require additional dependencies, but should not interrupt the build.
See our Dockerfiles (used e.g. on our CI systems) to get an idea what packages are required to build the entire libpmemobj-cpp, with all tests and examples.
1 C++11 is supported in GCC since version 4.8.1, but it does not support expanding variadic template variables in lambda expressions, which is required to build persistent containers and is possible with GCC >= 4.9.0. If you want to build libpmemobj-cpp without testing containers, use flag TEST_XXX=OFF (separate flag for each container).
2 radix_tree is supported on Windows with MSBuild >=15 (Visual Studio at least 2017 is needed). Testing radix_tree can be disabled via CMake option (use -DTEST_RADIX_TREE=OFF).
$ mkdir build
$ cd build
$ cmake .. [-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=<path_to_installation_dir>]
$ make
# make install
Note:
By default CMake's option USE_LIBUNWIND
is switched ON. If libunwind package was found
in the system, it is then linked to all tests' binaries. Sometimes this may lead to
failing a test, if it is run under Valgrind. To avoid this false-positive fails, you can
execute tests run under Valgrind separately, without libunwind:
cmake .. -DTESTS_USE_VALGRIND=ON -DUSE_LIBUNWIND=OFF && \
ctest -R "_helgrind|_pmemcheck|_drd|_memcheck|_pmreorder" # run only valgrind tests
or valgrind tests can be disabled in CMake build:
cmake .. -DTESTS_USE_VALGRIND=OFF && \
ctest
$ mkdir build
$ cd build
$ cmake .. -DCMAKE_BUILD_TYPE=Debug -DDEVELOPER_MODE=1 -DCHECK_CPP_STYLE=1
$ make
$ ctest --output-on-failure
$ mkdir build
$ cd build
$ cmake .. -DCPACK_GENERATOR="$GEN" -DCMAKE_INSTALL_PREFIX=/usr
$ make package
$GEN is type of package generator and can be RPM or DEB
CMAKE_INSTALL_PREFIX must be set to a destination were packages will be installed
In order to build your application with libpmemobj-cpp and pmemcheck / memcheck / helgrind / drd, Valgrind instrumentation must be enabled during compilation by adding flags:
If there are no memcheck / helgrind / drd / pmemcheck headers installed on your system, build will fail.
vcpkg install pmdk:x64-windows
vcpkg integrate install
cmake . -Bbuild -G "Visual Studio 14 2015 Win64"
-DCMAKE_TOOLCHAIN_FILE="c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake"
-DTEST_RADIX_TREE=OFF
msbuild build/ALL_BUILD.vcxproj /m
cmake . -Bbuild -G "Visual Studio 15 2017" -A "x64"
-DCMAKE_TOOLCHAIN_FILE="c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake"
msbuild build/ALL_BUILD.vcxproj /m
For custom build you can use CMake flags to change build type, change C++ standard, enable/disable components or features for testing purposes. To list all CMake flags use the following:
$ mkdir build
$ cd build
$ cmake ..
$ cmake -LH
or just use graphical CMake frontend like cmake-qt-gui or cmake-curses-gui.
If you read the blog post and still have some questions (especially about discontinuation of the project), please contact us using the dedicated e-mail: pmdk_support@intel.com.