Skip to main content

Getting Started: C / C++

Applies to
Windows
MacOS
Linux

Get started with our cross-platform C / C++ library.

The Velopack C / C++ library is a pre-compiled dynamic library, which you can link into your application to enable auto-updates and installers. There is a C and a C++ API available in Velopack.h, so this library is suitable for C / C++ application as well as other programming languages which support calling C functions eg. p/invoke.

tip

All the strings (eg. char* or std::string) are expected to be UTF-8 encoded. On Windows, you may need to convert wchar_t* and std::wstring to UTF-8 before passing it to the library.

1
Download Velopack C/C++ library

Download the latest velopack_libc_{version}.zip from GitHub Releases and include it into your project. Extract the contents of the zip file to a directory you can reference in your project.

2
Include Velopack in your project

Add the include directory from the extracted content to your include path, and add the appropriate binary from lib to your linker options. You will find both a lib and lib-static directories in the extracted contents.

3
Configure Velopack at the beginning of Main

Add VelopackApp to your entry point (eg. main() or wmain()) as early as possible, ideally the first statement to run:

#include "Velopack.h"

wmain(int argc**, wchar_t *argv[ ], wchar_t *envp[ ])
{
// This should run as early as possible in the main method.
// Velopack may exit / restart the app at this point.
// See VelopackApp class for more options/configuration.
Velopack::VelopackApp::Build().Run();

// ... your other startup code here
}
4
Add update check within your app

Velopack provides a simple way to check for updates and apply them. The following show how to implement a basic update check within your application.

You can also split up the various methods to allow your users to control when to check for updates, download them, or apply them.

#include "Velopack.h"

static void update_app()
{
Velopack::UpdateManager manager("https://the.place/you-host/updates");

auto updInfo = manager.CheckForUpdates();
if (!updInfo.has_value()) {
return; // no updates available
}

// download the update, optionally providing progress callbacks
manager.DownloadUpdates(updInfo.value());

// prepare the Updater in a new process, and wait 60 seconds for this process to exit
manager.WaitExitThenApplyUpdate(updInfo.value());
exit(0); // exit the app to apply the update
}
5
Compile your app

Compile your app to a program using your usual compiler (eg. msvc, cmake, gcc, etc)

6
Install vpk

Velopack uses a command line tool called vpk to package and publish releases. It is distributed as a .NET global tool. Though Velopack can be used with app from various languages, the .NET is required to install and run vpk. You can install the .NET SDK from the .NET download page.

Once .NET is installed, you can install vpk by running:

dotnet tool install -g vpk
7
Build Velopack release!

You are now ready to build a Velopack release for your application.

The --packId can be any unique application identifier that you wish to use. Because this must be unique across all applications, we recommend including your company name: <CompanyName>.<AppName>.

The --mainExe option is only required if your executable name is different than the --packId of your application.

See the CLI reference for more details on the available options.

vpk pack --packId YourAppId --packVersion 1.0.0 --packDir .\publish --mainExe yourMainApp.exe

✅ You're Done! Your app now has auto-updates and an installer. You can upload your release to your website, or use the vpk upload command to publish it to the destination of your choice.

You can also check out our Sample Apps to see completed examples that leverage Velopack.