import InstallVpk from './content/_install-vpk.mdx'; import BuildRelease from './content/_build-release.mdx'; import Completion from './content/_completion.mdx';
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.
:::
int 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
}
```
You can also split up the various methods to allow your users to control when to check for updates, download them, or apply them.
The URL passed to `UpdateManager` points at wherever you host your updates (a web server, S3 bucket, GitHub releases, etc.).
```cpp
#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
}
```
Unlike the C# and Python SDKs, the C / C++ library has no single apply-and-restart helper, so you call `WaitExitThenApplyUpdate` (which prepares the updater and waits for this process to exit) and then exit the app yourself via `exit(0)`.