Getting Started: C / C++
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.
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.
-
Download the latest
velopack_libc_{version}.zip
from GitHub Releases and include it into your project. -
Add the
include
directory to your include path, and add the appropriate binary fromlib
to your linker options. -
Add
VelopackApp
to your entry point (eg.main()
orwmain()
) 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
} -
Add auto-updates somewhere to your app:
#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
} -
Install the
vpk
command line tool:dotnet tool update -g vpk
tipYou must have the .NET Core SDK 8 installed to use and update
vpk
-
Compile your app to a program using your usual compiler (eg. msvc, cmake, gcc, etc)
-
Package your Velopack release / installers:
vpk pack -u MyAppUniqueId -v 1.0.0 -p /myBuildDir -e myexename.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.