![]() |
The library requires a C++11 compiler as a minimum and is regularly tested with the following compilers:
The library supports POSIX systems and Windows 10 and newer. Note that many operating systems not normally thought of as POSIX systems, such as mainframe legacy operating systems or embedded operating systems, support POSIX compatible file systems and so will work with the Filesystem Library.
Besides the operating systems mentioned above, the library has been used on HP-UX, IBM AIX, SGI IRIX, OpenBSD, FreeBSD and Sun Solaris operating systems using a variety of compilers. It is also used by several smart phone operating systems.
Cygwin version 1.7 or later is required because only versions of GCC with wide character strings are supported.
The library's implementation code treats Cygwin as a POSIX platform, and thus uses the POSIX API and path syntax as the native path syntax.
Boost.Filesystem is implemented as a separately compiled library, so you must install binaries in a location that can be found by your linker. If you followed the Boost Getting Started instructions, that's already been done for you.
Otherwise, the library can also be built manually using Boost.Build or CMake using the project files in the library directory. For example, using Boost.Build one can build a release version of the library with the following command line in the Boost root directory:
b2 --with-filesystem variant=release stage
With CMake, the library can be built with the following commands, also in the Boost root directory:
mkdir build_static_release cd build_static_release cmake .. -DCMAKE_BUILD_TYPE=Release -DBOOST_INCLUDE_LIBRARIES=filesystem cmake --build .
The library can be built for static or dynamic (shared/dll) linking. For
Boost.Build, this is controlled with the link
property
which can have values shared
and static. For example, to
build shared libraries:
b2 --with-filesystem variant=release link=shared stage
For CMake, the BUILD_SHARED_LIBS
option enables building shared libraries. Note that with CMake users typically
have to create a separate build directory for every build configuration.
mkdir build_shared_release cd build_shared_release cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=1 -DBOOST_INCLUDE_LIBRARIES=filesystem cmake --build .
When using Boost.Filesystem as a shared library, users should define BOOST_ALL_DYN_LINK or BOOST_FILESYSTEM_DYN_LINK
macros when compiling their code. This will configure the auto-linking process
to link with the shared library instead of the static one. See the Separate
Compilation page for more details.
Users may define the following macros if desired. Sensible defaults are provided, so users can ignore these macros unless they have special needs.
Some of the macros can be defined when compiling user's code, which will affect library interfaces. Other macros can be defined during Boost.Filesystem compilation, which affect library implementation. Those macros need not be defined when building code that uses Boost.Filesystem.
|
Macro Name |
Default |
Affects library usage |
Affects library build |
Effect if defined |
|---|---|---|---|---|
|
|
3 |
✔ |
Selects the Boost.Filesystem library version. Can have values of
3 or 4. Defining to 4 also implies |
|
|
|
Not defined |
✔ |
Deprecated features are excluded from headers. |
|
|
|
Defined if |
✔ |
The Boost.Filesystem library is dynamically linked. If not defined, static linking is assumed. |
|
|
|
Defined if |
✔ |
Boost.Filesystem library does not use the Boost auto-link facility. |
|
|
|
Not defined. |
✔ |
Boost.Filesystem library does not use the |
|
|
|
Not defined. |
✔ |
Boost.Filesystem library does not use the |
|
|
|
Not defined. |
✔ |
Boost.Filesystem library does not use the |
|
|
|
Not defined. |
✔ |
Boost.Filesystem library does not use the |
|
|
|
Not defined. |
✔ |
Boost.Filesystem library does not use the |
|
|
|
Not defined. BCrypt API presence detected at library build time. |
✔ |
Boost.Filesystem library does not use the BCrypt API on Windows. Has no effect on other platforms. |
In order to define macros when building Boost.Filesystem one can use define property with Boost.Build or -D option
with CMake. For example:
b2 --with-filesystem variant=release define=BOOST_FILESYSTEM_DISABLE_STATX stage
or:
mkdir build_static_release cd build_static_release cmake .. -DCMAKE_BUILD_TYPE=Release -DBOOST_INCLUDE_LIBRARIES=filesystem -DBOOST_FILESYSTEM_DISABLE_STATX cmake --build .
For new code using Boost.Filesystem, defining BOOST_FILESYSTEM_NO_DEPRECATED
before including filesystem headers is strongly recommended. This prevents
inadvertent use of old features, particularly legacy function names, that
have been replaced and are going to go away in the future.
Library components can be introduced by including one of the headers in the
boost/filesystem directory or boost/filesystem.hpp, which
includes all headers in boost/filesystem.
Library components are defined in the boost::filesystem
namespace.
Do not include headers from boost/filesystem/detail
directory or use symbols from the boost::filesystem::detail
namespace. Those are implementation details of the library, they are not
part of the public interface and may be changed or removed without notice.