Skip to main content

Getting Started: C++

Applies to
Windows
MacOS
Linux

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

  1. Copy Velopack.hpp and Velopack.cpp into your project.

  2. Configure Unicode Support:

    Windows

    On Windows, to enable unicode support for this library you must configure the UTF-8 code page via your application manifest. Failure to do so will potentially result in your application failing to update if there are any unicode characters in your user's file paths, username, etc.

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
    <application>
    <windowsSettings>
    <activeCodePage xmlns="http://schemas.microsoft.com/SMI/2019/WindowsSettings">UTF-8</activeCodePage>
    </windowsSettings>
    </application>
    </assembly>

    Linux & MacOS

    • If you are using Qt and QString is available, there's nothing further you need to do.
    • If you are not using Qt, you'll need to install ICU4C. Like many other C libraries, installing the development package with your package manager (apt, brew etc) should be sufficient to make it available to compilers.
  3. Add the Velopack::startup() to your entry point (eg. main() or wmain()) as early as possible, ideally the first statement to run:

    #include "Velopack.hpp"

    wmain(int argc**, wchar_t *argv[ ], wchar_t *envp[ ])
    {
    // Velopack may exit / restart your app at this statement
    Velopack::startup(argv, argc);

    // ... your other startup code here
    }
  4. Add auto-updates somewhere to your app:

    #include "Velopack.hpp"
    #include <memory>

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

    auto updInfo = manager.checkForUpdates();
    if (updInfo == nullptr) {
    return; // no updates available
    }

    manager.downloadUpdates(updInfo->targetFullRelease.get());
    manager.applyUpdatesAndRestart(updInfo->targetFullRelease.get());
    }
  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. Copy Vfusion.exe, VfusionMac or VfusionNix to your build output folder. This is a manual step for now, but may be automated in the future. You can compile this yourself, download a recent build artifact, or grab the latest npm release which also bundles the binaries.

    warning

    Until this is automated, failing to copy the fusion binary to your update directory will result in your app being unable to update.

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