Cross-platform C SDK logo

Cross-platform C SDK

GitHub integration

❮ 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 a multiplatform working environment, our code will move between different machines and compilers, which makes it almost essential to use a version control system to automate the task. Today there are several solutions and a multitude of websites that allow us to host our projects. We will focus here on the Git/GitHub tandem and see how to synchronize our private repositories with the NAppGUI in order to always have the latest published version of the SDK.

If you prefer not to use Git, you can jump directly to the Manual installation section. If you use Git but not GitHub, everything we see here will serve as a reminder by changing, of course, the URLs of the remote repositories.

1. Create a repository

The first step is to create a new repository to host your projects. Access your GitHub account and do it, it's simple. If you define it as Private, only the people you specify will have access to it. At the moment do not add the README, nor .gitignore nor license (Figure 1). After accepting, GitHub will show you the URL of your repository (Figure 2), which we will need later to link the local machine.

Repository creation page on GitHub.
Figure 1: Create a new repository on GitHub.
URL displayed by GitHub after creating a new repository.
Figure 2: Url of the newly created repository.

2. Upload your project to GitHub

If you have followed the Quick start and New project steps, you will now have a folder C:\nappgui_sdk with your first application MyNewApp on your Windows machine and various examples that come "standard" with the SDK. To begin, check the status of your local repository with git status.

C:\nappgui_sdk
 
git status

On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   src/CMakeLists.txt

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        src/myapp/

no changes added to commit (use "git add" and/or "git commit -a")

This indicates that you have modified CMakeLists.txt and that there is a folder (src/myapp of the new project) that is not yet under version control. Yes, indeed, when did git clone you created a local copy of the NAppGUI repository, so from the first moment you have your project audited by Git. What you need to do now is add a link to the GitHub repository that you just created. For this you must use the command git remote.

C:\nappgui_sdk
 
git remote add myrepo https://github.com/your_user/your_repo.git

At this moment your local folder has two connections with remote repositories (Figure 3): The first (called origin) with NAppGUI as a result of git clone and the second (myrepo) with your own repository, which is still empty. You can see it with git remote -v

C:\nappgui_sdk
 
git remote -v

myrepo  https://github.com/your_user/your_repo.git (fetch)
myrepo  https://github.com/your_user/your_repo.git (push)
origin  https://github.com/frang75/nappgui.git (fetch)
origin  https://github.com/frang75/nappgui.git (push)
Connection diagram with GitHub repositories.
Figure 3: Remote connections from your main machine (Windows).

Well now, you just have to add the new changes to the local repository:

C:\nappgui_sdk
 
git add .
git commit -m "MyNewApp first version"

[master 536bb09] MyNewApp first version
 9 files changed, 92 insertions(+)
 create mode 100644 src/myapp/CMakeLists.txt
 create mode 100644 src/myapp/mynewapp.c
 create mode 100644 src/myapp/res/banner.bmp
 create mode 100644 src/myapp/res/license.txt
 create mode 100644 src/myapp/res/logo.icns
 create mode 100644 src/myapp/res/logo256.ico
 create mode 100644 src/myapp/res/logo48.ico
 create mode 100644 src/myapp/res/pack.txt

And upload them to your GitHub

C:\nappgui_sdk
 
git push myrepo

Enumerating objects: 2525, done.
Counting objects: 100% (2525/2525), done.
Delta compression using up to 8 threads.
Compressing objects: 100% (1097/1097), done.
Writing objects: 100% (2525/2525), 49.37 MiB | 1.31 MiB/s, done.
Total 2525 (delta 1356), reused 2517 (delta 1353)
remote: Resolving deltas: 100% (1356/1356), done.
To https://github.com/frang75/test2.git
 * [new branch]      master -> master

If you access your repository from the GitHub website, you will see that you already have your project in a safe place (Figure 4).

Status of a GitHub repository, seen from the web interface.
Figure 4: Your local copy, already hosted on GitHub.
The NAppGUI repository is read-only. Any changes you try to post to it git push origin will be rejected.

3. Update working copies

As your new repository already contains the project and everything you need to compile on multiple platforms, you can clone it from any machine on your network, be it a PC-Windows, macOS or PC-Linux.

New machine
 
git clone https://github.com/your_user/your_repo.git

It is not necessary for all machines on your network to keep a remote reference with NAppGUI. You can keep the link on the Windows machine to update the SDK conveniently. The others will get the changes from your private repository. At this time, each machine on your network can upload changes to the repository, similar to the view in the previous section:

New machine
 
git add .
git commit -m "New changes in project"
git push

And to update the changes made by other colleagues, you will use git pull

New machine
 
git pull
It is very important that you run CMake again after updating the local copy of each machine. Other colleagues may have added files, forcing the solution to recompute.

4. Update the NAppGUI SDK

The NAppGUI repository is constantly being updated with new functionality and bug fixes. If you want to keep your project up to date, you can update periodically:

C:\nappgui_sdk>
 
git pull origin
git push myrepo

Which updates from NAppGUI and, later, uploads it to your private repository so that all machines have access to the changes.


5. Manual installation

If you don't want to use Git, have no link to the NAppGUI repository, or delete unnecessary files, you can install the SDK manually, following these simple steps:

  • Get the .ZIP of the SDK from the Download section of nappgui.com. Contains the same directory structure.
  • You can remove the README.md, if it is included in the package.
  • If you want to remove the sample projects, delete the /src/demo and /src/howto folders. Then open /src/CMakeLists.txt and delete all the lines below the # NAppGUI Sources, which are responsible for generating the example applications.

And to update the SDK once installed:

  • Download the new version .ZIP again and unzip it in a separate folder.
  • Completely replace the /inc, /lib and /prj folders of your working copy with those of the new package.
  • Open /src/CMakeLists.txt in your local copy and replace the lines under # NAppGUI Libraries with those of the new version. It is very likely that they have not changed, but check it.
  • Run CMake again so that it integrates all the changes into your solution.
❮ Back
Next ❯