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, that work on any desktop platform (Windows, macOS or Linux), using the C programming language (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. Quick start in Windows

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

  • Visual Studio to compile under Windows. Microsoft offers the free Community version for independent developers or small businesses. In this tutorial we will use VS2019, but you can use another version if you already have one installed.
  • CMake. Cross-platform tool to create compilation projects automatically, from source code. Be careful to select Add CMake to the system PATH for all users during installation (Figure 3).
  • Git. The well-known version control solution that we will use to download the software and synchronize our code between different machines.
  • Visual Studio, CMake, and Git icons.
    Figure 2: Visual Studio, CMake and Git, as basic tools in Windows.
    The CMake installer showing the PATH selection in Windows.
    Figure 3: CMake installation on Windows, allowing to use the command line.

Open the Developer Command Prompt for VS 2019 program (or the equivalent if you use another VS), which you can access from Programs->Visual Studio 2019. Go to the root directory C:\. The first step will be to obtain a copy of the SDK through GitHub:

C:\>
 
git clone --depth 1 https://github.com/frang75/nappgui.git nappgui_sdk

Create a working directory and go to it.

C:\>
 
mkdir nappgui_build
cd nappgui_build

Run CMake (from working directory). This command will automatically generate the NAppGUI.sln solution necessary to compile the examples and your future projects.

C:\nappgui_build>
 
cmake -G "Visual Studio 16 2019" ../nappgui_sdk/src

// Others -G values
Visual Studio 15 2017
Visual Studio 14 2015
Visual Studio 12 2013
Visual Studio 11 2012
Visual Studio 10 2010

Run msbuild from the same working directory.

C:\nappgui_build>
 
msbuild NAppGUI.sln

Once compiled, you will be able to run the existing example applications in the demo and howto directories (Figure 4).

C:\nappgui_build>
 
.\demo\die\Debug\Die.exe
.\demo\bricks\Debug\Bricks.exe
.\demo\products\Debug\Products.exe
.\howto\col2dhello\Debug\Col2dHello.exe
.\howto\guihello\Debug\GuiHello.exe
...
Running a sample application on Windows.
Figure 4: Running the Products sample program after compilation.

2. Quick start on macOS

Before starting, make sure you have installed and configured Xcode, an essential environment for development under macOS. You will also need to download and install CMake from www.cmake.org (Figure 5).

The CMake bundle about to be installed on macOS.
Figure 5: Xcode and CMake tools on macOS.
By default, CMake does not configure command line access on macOS. You can create a symbolic link with sudo ln /Applications/CMake.app/Contents/bin /cmake /usr/local/bin.

Open a terminal and check that the command line tools work:

 
xcodebuild
cmake
git

Then get the SDK through GitHub

 
git clone --depth 1 https://github.com/frang75/nappgui.git nappgui_sdk

Create a working directory

 
mkdir nappgui_build
cd nappgui_build

Run CMake (from working directory). This command will automatically generate the project NAppGUI.xcodeproj necessary to compile the examples and your future projects.

~/nappgui_build
 
cmake -G "Xcode" ../nappgui_sdk/src

Run xcodebuild from the same working directory.

~/nappgui_build
 
xcodebuild

Once compiled, you can run the existing sample applications in the directories demo and howto (Figure 6).

~/nappgui_build
1
2
3
4
5
6
./demo/die/Debug/Die.app/Contents/MacOS/Die
./demo/bricks/Debug/Bricks.app/Contents/MacOS/Bricks
./demo/products/Debug/Products.app/Contents/MacOS/Products
./howto/col2dhello/Debug/Col2dHello.app/Contents/MacOS/Col2dHello
./howto/guihello/Debug/GuiHello.app/Contents/MacOS/GuiHello
...
Running a sample application on macOS.
Figure 6: Running the Bricks sample program after compilation.

3. Quick start on Linux

Before starting, make sure you have the necessary compilers, tools and libraries installed:

 
// Development tools
sudo apt-get install gcc
sudo apt-get install g++
sudo apt-get install git
sudo apt-get install make
sudo apt-get install cmake

// Development libraries
sudo apt-get install libgtk-3-dev
sudo apt-get install libglu1-mesa-dev freeglut3-dev mesa-common-dev
sudo apt-get install libcurl4-openssl-dev
NAppGUI requires at least gcc 4.6, gtk3 (for desktop applications), OpenGL (if your application uses 3D graphics) and Curl (for Web protocols). All this is included as of Ubuntu 12.04 LTS or similar distributions.

Open a terminal and get the SDK via GitHub

 
git clone --depth 1 https://github.com/frang75/nappgui.git nappgui_sdk

Create a working directory

 
mkdir nappgui_build
cd nappgui_build

Run CMake (from working directory). This command will automatically generate the Makefiles necessary to compile the examples and your future projects.

~/nappgui_build$
 
cmake -G "Unix Makefiles" ../nappgui_sdk/src

Run make from the same working directory.

~/nappgui_build$
 
make

Once compiled, you will be able to launch the existing example applications in the demo and howto directories (Figure 7).

~/nappgui_build$
 
./demo/die/Debug/Die
./demo/bricks/Debug/Bricks
./demo/products/Debug/Products
./howto/col2dhello/Debug/Col2dHello
./howto/guihello/Debug/GuiHello
...
Running a sample application on Linux.
Figure 7: Running the Col2dHello sample program after compilation.

4. MIT License

NAppGUI is distributed under the MIT license, which essentially means that you have complete freedom to use this software freely and for free, both in commercial and free projects. The only restriction is that you must include a copy of this License in every substantial part of the software you distribute.


5. Previous knowledge

This book is not intended for beginners. Although the NAppGUI project is aimed at simplifying the construction of cross-platform applications, it requires certain prior knowledge on the part of the user. You will need, at least, to be fluent in C or C++ since at no time we will stop to explain basic programming concepts. If you come from Java or C#, you should review pointers. You will also need some skill with Visual Studio and Xcode development environments, and Unix tools such as gcc, make or the command interpreter.

On the other hand, if you are an advanced user, you will find a simple system to create very fast and small C applications that will compile without changes in all desktop environments. You will also have at your disposal a set of precompiled C libraries to create user interfaces or command line applications, without the need to mess up your projects with the cumbersome class templates that stl or boost provide.


6. And now what?

  • In Welcome to NAppGUI we continue with a detailed tutorial.
  • In Hello, World! we see step by step the minimum code of a desktop application.
  • In New project you will start creating your own applications.
  • In Portability you will have more detailed information on migration between platforms.
  • In The Big Picture you have the complete documentation of the NAppGUI libraries and functions.
  • In Products you have the source code of a medium-sized application, fully explained.
Next ❯