When we introduced version 2.0 of the command line library, we modified our compilation scripts and realized that we had never explained how to compile the command line library.
The command line API is actually a series of applications written in C++ that use our C++ library. The "Source" directory contains the tools' sources. Our C++ programming library is included in the "cpplib" subdirectory. To compile a tool, you need to compile the corresponding source files, some common files, and the C++ programming library. You must also define the CMD_xxx macro (where xxx is the name of the tool) at compile time, so that the C preprocessor uses the correct version of the code.
In concrete terms, to compile the YAltitude.exe tool, you need to compile:
- The YAltitude.cpp file in the "Source" directory.
- The cmdline_linker.cpp and cmdline_common.cpp files in the "Source" directory.
- All C++ files in the "Source/cpplib" directory.
- All C files in the "Source/cpplib/yapi" directory.
- All C files in the "Source/cpplib/yapi/mbedtls/library" directory.
Make sure the following directories are part of the include path:
- The "Source/cpplib" directory.
- The "Source/cpplib/yapi" directory.
- The "Source/cpplib/yapi/mbedtls/include" directory.
When compiling, use the -D CMD_YAltitude option (or /D CMD_YAltitude) for the compiler to define the "CMD_YAltitude" macro.
GNU Makefile
As you can see, compilation is tedious and for this reason we have a GNU Makefile that manages the compilation of all tools for all platforms.
To compile the library, simply go to the "Binaries" directory and type make. The Makefile will compile all tools for the current OS. If you only need a specific tool, you can specify the target like this:
Cygwin
For compilation under Windows, we've decided to use the GNU Makefile as well, even though it was originally a Linux tool. This allows us to simplify our build scripts and finely control compilation options. The disadvantage of this solution is that GNU Make must be installed on Windows.
To install GNU Make, several solutions exist, but the two most widespread are Cygwin and GnuWin32. Both solutions work, the choice depends on your preferences.
Conclusion
The command-line library is available on our website (and on our APT repository). All archive files contain the tools already compiled and ready for use. So you shouldn't need to recompile them, but if you want to port them to another platform or modify the source code, you now know how to compile this library.