Build NAppGUI
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. We will start within the previously downloaded project folder:
|
git clone --depth 1 https://github.com/frang75/nappgui_src.git cd nappgui_src |
1. Static linking
The following commands will generate the static link version of the libraries that make up NAppGUI.
|
// 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 -DNAPPGUI_DEMO=NO -DCMAKE_BUILD_TYPE=Release cmake --build build -j 4 cmake --install build --config Release --prefix /usr/local/nappgui |
For CMake versions lower than 3.13:
|
// Windows mkdir build & cd build cmake .. -DNAPPGUI_DEMO=NO -DCMAKE_INSTALL_PREFIX=C:/nappgui cmake --build . --config Release msbuild INSTALL.vcxproj /p:Configuration=Release // macOS mkdir build ; cd build cmake .. -G Xcode -DNAPPGUI_DEMO=NO -DCMAKE_INSTALL_PREFIX=/usr/local/nappgui cmake --build . --config Release xcodebuild -target install -configuration Release // Linux mkdir build ; cd build cmake .. -DNAPPGUI_DEMO=NO -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/nappgui cmake --build . make install |
2. Dynamic linking
If you prefer to generate NAppGUI in dynamic link mode (.dll, .so, .dylib), follow these instructions.
|
// 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 -DNAPPGUI_DEMO=NO -DNAPPGUI_SHARED=YES -DCMAKE_BUILD_TYPE=Release cmake --build build -j 4 cmake --install build --config Release --prefix /usr/local/nappgui |
For CMake versions lower than 3.13:
|
// Windows mkdir build & cd build cmake .. -DNAPPGUI_DEMO=NO -DNAPPGUI_SHARED=YES -DCMAKE_INSTALL_PREFIX=C:/nappgui cmake --build . --config Release msbuild INSTALL.vcxproj /p:Configuration=Release // macOS mkdir build ; cd build cmake .. -G Xcode -DNAPPGUI_DEMO=NO -DNAPPGUI_SHARED=YES -DCMAKE_INSTALL_PREFIX=/usr/local/nappgui cmake --build . --config Release xcodebuild -target install -configuration Release // Linux mkdir build ; cd build cmake .. -DNAPPGUI_DEMO=NO -DNAPPGUI_SHARED=YES -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/nappgui cmake --build . make install |
If you use NAppGUI in DLL mode you must ensure that your future applications find the libraries, updating the PATH
variable of each system.
|
// Windows set PATH=C:\nappgui\bin;%PATH% // Linux export LD_LIBRARY_PATH=/usr/local/nappgui/bin:$LD_LIBRARY_PATH$ // macOS export DYLD_LIBRARY_PATH=/usr/local/nappgui/bin:$DYLD_LIBRARY_PATH$ |
3. CMake Options
We indicate below all the CMake options supported by NAppGUI. In Generators, compilers and IDEs you will have more detailed information.
|
cmake -G [Generator] -S [SourceDir] -B [BuildDir] [Options] |
-G
: CMake Generators. If omitted, the value ofCMAKE_GENERATOR
or a default will be used.-S
: Directory where the NAppGUI fileCMakeLists.txt
is located.-B
: Directory where the compilation projects and binaries will be generated.-DNAPPGUI_DEMO=[YES|NO]
: Generate the example applications. By defaultYES
.-DNAPPGUI_SHARED=[YES|NO]
: Generates dynamic link libraries (.dll, .so, .dylib). By defaultNO
.-DNAPPGUI_WEB=[YES|NO]
: Add native support for theWebView
control. By defaultYES
. See Disable WebView.-DCMAKE_BUILD_TYPE=[Debug|Release]
: In mono-configuration generators, eg. Unix Makefiles, configure the build mode. By defaultDebug
.-DCMAKE_C_COMPILER=[gcc|clang|cl]
: On Unix Makefiles, MinGW, MSYS or Ninja select the C compiler.-DCMAKE_CXX_COMPILER=[g++|clang++|cl]
: On Unix Makefiles, MinGW, MSYS, or Ninja, select the C++ compiler.-A=[Win32|x64]
: In Windows select the target architecture.-DCMAKE_ARCHITECTURE=[x64|i386|arm|arm64]
: On Linux or macOS, select the target architecture. By default, that of the compilation machine.arm
is not supported on macOS.i386
is restricted on macOS. See macOS 32bits.-DCMAKE_OSX_DEPLOYMENT_TARGET=12.4
: In macOS, minimum version of the operating system supported. By default, the most modern one included in the compiler. See Xcode.-DCMAKE_TOOLKIT=GTK3
: In Linux it indicates the graphical toolkit used to render the interface elements. At the moment, onlyGTK3
.-DCMAKE_DISABLE_CRTDBG=YES
: Disables thecrtdbg
library on Windows that controls memory leaks during execution. In principle, its use is not recommended, but it can be useful in projects that use third-party libraries with static or singleton objects.
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] |
--build
: Directory where the build projects are located (configuration parameter-B
).--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 the executables and dynamic libraries in [BuildDir]/[Debug|Release]/bin
. 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] |
--install
: Directory where the binaries are located (configuration parameter-B
).--config
: Configuration to be packaged (Debug or Release).--prefix
: Installation 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 (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 └── cmake ├── nappgui-config.cmake ├── ... |
In the /bin
folder the DLLs will be installed, if we have chosen the dynamic link.
Library names are different on Windows (XXXX.lib) than on Linux/macOS (libXXXX.a).