Skip to content

Commit 929e364

Browse files
committed
Update C++ quick start
1 parent 4dc320d commit 929e364

File tree

4 files changed

+48
-53
lines changed

4 files changed

+48
-53
lines changed

docs/getting-started/cpp.mdx

Lines changed: 31 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,54 @@
1-
# Getting Started: C++
1+
# Getting Started: C / C++
22
<AppliesTo all />
3-
Get started with our cross-platform C++ header library.
4-
5-
1. Copy [Velopack.hpp](https://github.com/velopack/velopack.fusion/blob/master/for-cpp/Velopack.hpp) and [Velopack.cpp](https://github.com/velopack/velopack.fusion/blob/master/for-cpp/Velopack.cpp) into your project.
6-
7-
0. Configure Unicode Support:
8-
#### Windows
9-
On Windows, to enable unicode support for this library you ***must***
10-
[configure the UTF-8 code page](https://learn.microsoft.com/en-us/windows/apps/design/globalizing/use-utf8-code-page) via your application
11-
manifest. Failure to do so will potentially result in your application ***failing to update*** if there are any unicode characters in your user's
12-
file paths, username, etc.
13-
```xml
14-
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
15-
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
16-
<application>
17-
<windowsSettings>
18-
<activeCodePage xmlns="http://schemas.microsoft.com/SMI/2019/WindowsSettings">UTF-8</activeCodePage>
19-
</windowsSettings>
20-
</application>
21-
</assembly>
22-
```
23-
#### Linux & MacOS
24-
- If you are using Qt and `QString` is available, there's nothing further you need to do.
25-
- If you are not using Qt, you'll need to [install ICU4C](https://icu.unicode.org/). Like many other C libraries,
26-
installing the development package with your package manager (`apt`, `brew` etc) *should* be sufficient to make it available to compilers.
3+
Get started with our cross-platform C / C++ library.
4+
5+
The Velopack C / C++ library is a pre-compiled dynamic library, which you can link into your application to enable auto-updates and installers.
6+
There is a C and a C++ API available in [Velopack.h](https://github.com/velopack/velopack/blob/develop/src/lib-cpp/include/Velopack.h),
7+
so this library is suitable for C / C++ application as well as other programming languages which support calling C functions eg. p/invoke.
8+
9+
:::tip
10+
All the strings (eg. `char*` or `std::string`) are expected to be UTF-8 encoded.
11+
On Windows, you may need to convert `wchar_t*` and `std::wstring` to UTF-8 before passing it to the library.
12+
:::
13+
14+
1. Download the latest `velopack_libc_{version}.zip` from [GitHub Releases](https://github.com/velopack/velopack/releases) and include it into your project.
2715

28-
0. Add the `Velopack::startup()` to your entry point (eg. `main()` or `wmain()`) as early as possible, ideally the first statement to run:
16+
0. Add the `include` directory to your include path, and add the appropriate binary from `lib` to your linker options.
17+
18+
0. Add `VelopackApp` to your entry point (eg. `main()` or `wmain()`) as early as possible, ideally the first statement to run:
2919
```cpp
30-
#include "Velopack.hpp"
20+
#include "Velopack.h"
3121

3222
wmain(int argc**, wchar_t *argv[ ], wchar_t *envp[ ])
3323
{
34-
// Velopack may exit / restart your app at this statement
35-
Velopack::startup(argv, argc);
24+
// This should run as early as possible in the main method.
25+
// Velopack may exit / restart the app at this point.
26+
// See VelopackApp class for more options/configuration.
27+
Velopack::VelopackApp::Build().Run();
3628

3729
// ... your other startup code here
3830
}
3931
```
4032

4133
0. Add auto-updates somewhere to your app:
4234
```cpp
43-
#include "Velopack.hpp"
44-
#include <memory>
35+
#include "Velopack.h"
4536

4637
static void update_app()
4738
{
48-
Velopack::UpdateManagerSync manager{};
49-
manager.setUrlOrPath("https://the.place/you-host/updates");
39+
Velopack::UpdateManager manager("https://the.place/you-host/updates");
5040

51-
auto updInfo = manager.checkForUpdates();
52-
if (updInfo == nullptr) {
41+
auto updInfo = manager.CheckForUpdates();
42+
if (!updInfo.has_value()) {
5343
return; // no updates available
5444
}
5545

56-
manager.downloadUpdates(updInfo->targetFullRelease.get());
57-
manager.applyUpdatesAndRestart(updInfo->targetFullRelease.get());
46+
// download the update, optionally providing progress callbacks
47+
manager.DownloadUpdates(updInfo.value());
48+
49+
// prepare the Updater in a new process, and wait 60 seconds for this process to exit
50+
manager.WaitExitThenApplyUpdate(updInfo.value());
51+
exit(0); // exit the app to apply the update
5852
}
5953
```
6054

@@ -69,11 +63,6 @@ Get started with our cross-platform C++ header library.
6963

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

72-
0. 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](https://github.com/velopack/velopack.fusion/actions), or grab the latest [npm release](https://www.npmjs.com/package/velopack?activeTab=code) which also bundles the binaries.
73-
:::warning
74-
Until this is automated, failing to copy the fusion binary to your update directory will result in your app being unable to update.
75-
:::
76-
7766
0. Package your Velopack release / installers:
7867
```sh
7968
vpk pack -u MyAppUniqueId -v 1.0.0 -p /myBuildDir -e myexename.exe

docs/index.mdx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,18 @@ You can host updates anywhere static files can be served, eg. cloud file storage
3232
## Language Support
3333
There are libraries planned or supported for the languages below.
3434

35-
| Lang | Status | Runtime Deps | Async | Links |
36-
|:-:|---|---|---|---|
37-
| C# | ✅ Ready | ✅ None | ✅ Yes | [quick start](./getting-started/csharp.mdx), [docs](./reference/cs/Velopack/), [nuget.org](https://nuget.org/packages/velopack) |
38-
| Rust | ✅ Ready | ✅ None | ✅ Yes | [quick start](./getting-started/rust.mdx), [docs](https://docs.rs/velopack), [crates.io](https://crates.io/crates/velopack) |
39-
| JS | ✅ Ready | ✅ None | ✅ Yes | [quick start](./getting-started/electron.mdx), [docs](./reference/js), [npmjs.com](https://www.npmjs.com/package/velopack) |
40-
| C++ | 🔶 Experimental | 🔶 vfusion.exe | ❌ No | [quick start](./getting-started/cpp.mdx), [docs](./reference/cpp/api.md), [velopack.hpp](https://github.com/velopack/velopack.fusion/tree/master/for-cpp) |
41-
| Java | Planned | - | - | - | - |
42-
| Python | Planned | - | - | - | - |
43-
| Swift | Planned | - | - | - | - |
44-
| Go | Planned | - | - | - | - |
35+
| Lang | Status | Links |
36+
|:-:|---|---|
37+
| C# | ✅ Ready | [quick-start](./getting-started/csharp.mdx), [docs](./reference/cs/Velopack/), [nuget.org](https://nuget.org/packages/velopack) |
38+
| Rust | ✅ Ready | [quick-start](./getting-started/rust.mdx), [docs](https://docs.rs/velopack), [crates.io](https://crates.io/crates/velopack) |
39+
| JS | ✅ Ready | [quick-start](./getting-started/electron.mdx), [docs](./reference/js), [npmjs.com](https://www.npmjs.com/package/velopack) |
40+
| C++ | ✅ Ready | [quick-start](./getting-started/cpp.mdx), [docs](./reference/cpp/api.md), [gh-releases](https://github.com/velopack/velopack/releases) |
41+
| Java | Planned | - | - |
42+
| Python | Planned | - | - |
43+
| Swift | Planned | - | - |
44+
| Go | Planned | - | - |
45+
46+
Don't see your language here? [Open an issue](https://github.com/velopack/velopack/issues/new) to request and tell us how great it is!
4547

4648
## Migrating to Velopack
4749
It should be easy to migrate to Velopack from other update frameworks. We do have some guides, but if we're missing one for your case please let us know about it on GitHub or Discord!

docs/reference/cpp/api.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
:::warning
2+
## This page is currently out of date. Please see the [C++ Quick Start](../../getting-started/cpp.mdx) for the most accurate information.
3+
:::
4+
15
# Velopack C++ Reference
26

37
Members | Descriptions

sidebars.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const sidebars: SidebarsConfig = {
4444
label: 'Quick Start',
4545
items: [
4646
doc("getting-started/csharp", "C# / .NET"),
47-
doc("getting-started/cpp", "C++"),
47+
doc("getting-started/cpp", "C / C++"),
4848
doc("getting-started/electron", "JS / Electron"),
4949
doc("getting-started/rust", "Rust"),
5050
doc("getting-started/uno", "C# / Uno Platform"),

0 commit comments

Comments
 (0)