This is a full guide on how to get started with the AddonHost and implement your own addon. This guide will remain build-system agnostic and avoid compiler extensions where possible.
If all you need is an example, see The Compass Addon (Built with Visual Studio)
Alternately, see NexPad for a GNU make + GCC example using Msys2
Each addon loaded by nexus is required to export a function matching the signature AddonDefinition_t* GetAddonDef(). See AddonDefinition_t for the full struct definition
Example implementation of GetAddonDef
Fields not explicitly marked as optional are required.
Load() will be called when your addon is loaded, and should initialize anything your addon needs. The AddonAPI_t* it receives will contain a version of the nexus API matching the one specified in AddonDef.APIVersion. See AddonAPI_t for the current version of that API.
Unload() will be called when the game shuts down, when your addon is updated, and when it is unloaded. If your addon should not be able to be unloaded at runtime, set AddonDef.Flags to EAddonFlags::DisableHotloading.
If your addon is hosted on Raidcore, this should be the unique ID of your addon.
If your addon is not hosted on Raidcore, it should be any negative integer.
If you don't use any of Nexus's functions, set APIVersion to 0.
If APIVersion is a non-zero value, it must be a current or previous NEXUS_API_VERSION.
It is recommended to store the reference to the addon API in a shared place, so you can include it in any files that need it. An example of how to do this is shown below.
Shared.hShared.cppModuleMain.cppWhen AddonDefinition_t::Unload() is called, you should free any resources you have allocated. E.G. Keybinds.
Nexus will do its best to clean up after you should you forget, but no guarantee is made that it will do so perfectly.
To prevent memory leaks, clean up after yourself.