Cross-platform C SDK logo

Cross-platform C SDK

Quick start

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.

"...the number of UNIX installations has grown to 10, with more expected..." Dennis Ritchie and Ken Thompson - June 1972

NAppGUI is an SDK to develop software projects using the C programming language, that work on any desktop platform (Windows, macOS or Linux) (Figure 1). C++ is allowed, but not indispensable. We can write a complete program using only ANSI-C.

Capture an application on Windows, macOS and Linux written in C with NAppGUI.
Figure 1: NAppGUI allows the easy port of applications written in ANSI C.

1. Prerequisites

Before start you need to have installed these tools (Figure 2):

  • Visual Studio 2019 to compile under Windows. Microsoft offers the free Community version for independent developers or small companies.
  • CMake. Cross-platform tool to automatically create build projects from the source code.
  • Visual Studio and CMake icons.
    Figure 2: Visual Studio 2019 and CMake.

2. Installation

All you have to do is unzip the .zip file with the latest version or clone the GitHub repository. In it are the four folders that will make up your local working copy (Figure 3). We will assume that they are located in the C:\nappgui directory.

Capture of the downloaded and decompressed working copy.
Figure 3: Working copy ready to use.
  • inc: SDK header files.
  • lib: Pre-compiled versions of the NAppGUI libraries.
  • prj: Scripts that CMake will use to generate the projects.
  • src: Source code of the examples and future location of your own projects.

3. Compile the examples

We will create a solution in Visual Studio and compile one of the sample applications.

  • Open CMake (Figure 5).
  • Where is the source code: C:\nappgui\src.
  • Where to build the binaries: C:\nappgui_build. This new directory is generated automatically and must be out of version control.
  • Press [Configure]. CMake will ask for the compiler version. We use Visual Studio 2019 (Figure 4).
  • Capture the CMake dialog to set the generator.
    Figure 4: CMake compiler selection. This screen will only appear the first time.
  • Press [Generate] (Figure 5). The solution NAppGUI.sln will be created in C:\nappgui_build.
  • Press [Open Project] to open the solution in Visual Studio.
  • Capture CMake generating the solution in Visual Studio.
    Figure 5: Generation of NAppGUI.sln using CMake.
  • Already inside Visual Studio, Build->Build Solution.
  • Right click on demo/Products in the Solution Explorer and Set as StartUp Project.
  • Debug->Start Debugging.
  • We can now debug the example application Products (Figure 6).
  • Capture the Visual Studio debugger by running the sample application.
    Figure 6: Debugging examples in Visual Studio.
We recommend that you spend some time browsing, compiling and testing the examples.

4. Create a new project

To create a new desktop application, open the file src/CMakeLists.txt of your working copy. Go to the end of the file and add this line:

# Your projects here!
desktopApp("MyApp" "myapps/myapp" "" NRC_EMBEDDED)

Press again [Generate] in CMake, which will create the project in /src/myapps/myapp (Figure 7). Visual Studio will detect the changes and import the new project. It is ready to compile and run (Figure 8).

New project in CMake.
Figure 7: CMake has created and configured the new project.
Capture of the newly created application.
Figure 8: Running the new application.
You can locate the projects at any depth level within /src. Paths like "myapps/games/mygame" or just "mygame" are perfectly valid.

5. And now what?

  • In Welcome to NAppGUI we continue with a detailed tutorial.
  • In Products you have more details about the sample application you have run.
  • In New project you will see how to add files and resources to projects.
  • In Portability we will give detailed information on migration and cross-platform compilation.
  • In SDK reference you have the complete documentation of the libraries and functions.
Next ❯