Cross-platform C SDK logo

Cross-platform C SDK

Build NAppGUI

❮ Back
Next ❯
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. Now we will focus on installing the SDK in order to start creating our own applications. Follow these steps to download, compile and install the static link version of the 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

If you prefer to generate NAppGUI in dynamic link mode (.dll, .so, .dylib), follow these instructions.

 
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

If you use NAppGUi in DLL mode you must ensure that your future applications find the libraries, updating the PATH variable of each system.

  • On Windows, add the installation directory /bin to the PATH environment variable. e.g. C:\nappgui\bin.
  • On Linux: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH$:/usr/local/nappgui/bin.
  • On macOS: export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH$:/usr/local/nappgui/bin.

1. Configuration options

Initially, CMake must prepare the build projects. In Generators, compilers and IDEs you will have more exhaustive information about the particularities of each platform.

 
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. Also supports Debug (by default).
  • -DNAPPGUI_SHARED=YES: Generate dynamic link libraries (.dll, .so, .dylib), instead of static link (default).

2. 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]
  • --build: Directory where the build projects are located (parameter -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.


3. 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]
  • --install: Directory where build projects are located (parameter -B in configuration).
  • --config: Configuration to be packaged (Debug or Release).
  • --prefix: Package destination directory. If omitted, CMake will use the default system directories: /usr/local on UNIX or C:/Program Files/${PROJECT_NAME} on Windows.
To install in system directories (without the --prefix), 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
❮ Back
Next ❯