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 the latest velopack_libc_{version}.zip from GitHub Releases and include it into your project.

  2. Add the include directory to your include path, and add the appropriate binary from lib to your linker options.

  3. 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 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
    }
  5. Install the vpk command line tool:

    dotnet tool update -g vpk
    tip

    You must have the .NET Core SDK 8 installed to use and update vpk

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

  7. 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.