Option++
2.0
C++ library for reading command-line options
|
How to build Option++ and integrate it with your project
To use the single-header version of the library, just download the optionpp.hpp header file and place it inside an optionpp
directory somewhere within your project directory (a subdirectory called 'third_party' or something similar is a typical location).
Make sure your compiler, IDE, or build system is configured to search for includes in the subdirectory containing the optionpp
directory. Then #include <optionpp/optionpp.hpp>
where needed.
There is one more thing to do: in order to avoid multiple definitions, the single-header version looks for a macro called OPTIONPP_MAIN
in order to conditionally compile class method definitions. This means that in exactly one of your source files where you #include <optionpp/optionpp.hpp>
, you need to add #define OPTIONPP_MAIN
before the #include
statement.
To build the library, you will need a compiler supporting C++11, along with CMake version 3.10 or higher. To easily clone the repository, a git
installation is also recommended.
First clone the repository with git clone https://github.com/gkikola/optionpp.git
. Then, from the root of the main project directory, run
This will create several files:
To compile the library only, you can use make optionpp
.
Use git
to clone the repository: git clone https://github.com/gkikola/optionpp.git
.
Create a build
directory within the root project directory. Open a command prompt, navigate to the build
directory, and run cmake ..
to create the Visual C++ project files.
Open the solution file OPTIONPP.sln
in Visual Studio. In the menu, select Build > Build Solution. This will build several projects:
Under the default Debug configuration, the resulting library and executable files will be located in the build\Debug
directory.
If Visual Studio gives you the error message "Error HRESULT E_FAIL has been returned from a call to a COM component" try this:
.vs
directory from the build
directory.