Build NAppGUI from source code
This page has been automatically translated using the Google Translate API services. We are working on improving texts. Thank you for your understanding and patience.
In Quick start we already saw how to compile and run the examples from the source code. In this chapter and in Compilers and IDEs we will delve into the compilation, installation and portability process between platforms. Once the SDK is installed, you can continue at Create new application.
1. Build static libraries
|
git clone --depth 1 https://github.com/frang75/nappgui_src.git cd nappgui_src // Windows cmake -S . -B build -DNAPPGUI_DEMO=NO cmake --build build --config Release -j 4 cmake --install build --config Release --prefix C:/nappgui // macOS cmake -G Xcode -S . -B build -DNAPPGUI_DEMO=NO cmake --build build --config Release -j 4 cmake --install build --config Release --prefix /usr/local/nappgui // Linux cmake -S . -B build -DCMAKE_BUILD_TYPE=Release cmake --build build -j 4 cmake --install build --config Release --prefix /usr/local/nappgui |
2. Build shared libraries
|
git clone --depth 1 https://github.com/frang75/nappgui_src.git cd nappgui_src // Windows cmake -S . -B build -DNAPPGUI_DEMO=NO -DNAPPGUI_SHARED=YES cmake --build build --config Release -j 4 cmake --install build --config Release --prefix C:/nappgui // macOS cmake -G Xcode -S . -B build -DNAPPGUI_DEMO=NO -DNAPPGUI_SHARED=YES cmake --build build --config Release -j 4 cmake --install build --config Release --prefix /usr/local/nappgui // Linux cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DNAPPGUI_SHARED=YES cmake --build build -j 4 cmake --install build --config Release --prefix /usr/local/nappgui |
3. Configuration options
Initially, CMake must prepare the build projects.
|
cmake -G [Generator] -S [SourceDir] -B [BuildDir] [Options] |
- -G: CMake Generators. If omitted, the value of
CMAKE_GENERATOR
or a default will be used. - -S: Directory where the NAppGUI
CMakeLists.txt
file is located. - -B: Directory where the compilation projects and binaries will be generated.
- -DNAPPGUI_DEMO=NO: Does not generate the example applications. Only the essential SDK libraries.
- -DCMAKE_BUILD_TYPE=Release: In mono-configuration generators, eg. Unix Makefiles, configure to compile in release mode. Default: Debug.
- -DNAPPGUI_SHARED=YES: Generate dynamic link libraries (.dll, .so, .dylib), instead of static ones (default).
4. Build Options
Once the scripts have been generated in the previous step, we launch the compilation using CMake.
|
cmake --build [BuildDir] --config [Debug|Release] -j [NumProcs] |
- BuildDir: Directory where build projects are located (-B in configuration).
- --config: In multi-configuration generators, eg. Visual Studio indicates which configuration to compile (Debug or Release).
- -j: Number of concurrent compilation processes or threads.
After compilation we will have in [BuildDir]/[Debug|Release]/bin
the generated executables and dynamic libraries. In /lib
the static libraries.
5. Packaging and installation
After compilation we package the binaries and headers in order to have them available when creating our own applications.
|
cmake --install [BuildDir] --config [Debug|Release] --prefix [PackagePath] |
- BuildDir: Directory where build projects are located (-B in configuration).
- --config: Configuration to be packaged (Debug or Release).
- PackagePath: Package destination directory. If omitted, CMake will use the default system directories:
/usr/local
on UNIX orC:/Program Files/${PROJECT_NAME}
on Windows.
To install in system directories, we may have to run cmake install in administrator mode.
In the destination path we will have this file and directory structure:
|
nappgui ├── bin │ ├── nrc ├── inc │ ├── core │ │ ├── array.h │ │ ├── arrpt.h │ │ ├── ... │ ├── draw2d │ │ ├── color.h │ │ ├── dctx.h │ │ ├── ... │ ├── geom2d │ │ ├── box2d.h │ │ ├── box2d.hpp │ │ ├── ... │ ├── gui │ │ ├── button.h │ │ ├── cell.h │ │ ├── ... │ ├── inet │ │ ├── base64.h │ │ ├── httpreq.h │ │ ├── ... │ ├── nappgui.h │ ├── osapp │ │ ├── osapp.def │ │ ├── osapp.h │ │ ├── ... │ ├── osbs │ │ ├── bfile.h │ │ ├── bmutex.h │ │ ├── ... │ ├── osgui │ │ ├── osbutton.h │ │ ├── oscombo.h │ │ ├── ... │ ├── sewer │ │ ├── arch.hxx │ │ ├── blib.h │ │ ├── ... ├── lib │ ├── libcore.a │ ├── libdraw2d.a │ ├── libgeom2d.a │ ├── libgui.a │ ├── libinet.a │ ├── libosapp.a │ ├── libosbs.a │ ├── libosgui.a │ ├── libsewer.a └── prj ├── CMakeTarget.cmake ├── ... └── version.txt |