This guide explains how to build the Alpaca Zorro Plugin from source.
- Visual Studio 2022 (Professional or Community Edition)
- C++ Desktop Development workload
- Windows 10 SDK
- CMake 3.16 or higher
- Git (for cloning the repository)
- Zorro Trading Platform (for testing and automatic deployment)
- Ninja or Visual Studio Code (alternative build tools)
git clone https://github.com/kzhdev/alpaca_zorro_plugin.git
cd alpaca_zorro_pluginNote: All dependencies are included in the
3rdpartyfolder. No submodule initialization is needed.
- Launch CMake GUI
- Source directory: Browse to the cloned
alpaca_zorro_pluginfolder - Build directory: Browse to
alpaca_zorro_plugin/build - Click Configure
- Select Visual Studio 17 2022
- Choose platform: Win32 (x86) or x64
- Click Generate
- Click Open Project to launch Visual Studio
For x86 (Win32) build:
cmake -B build -G "Visual Studio 17 2022" -A Win32For x64 build:
cmake -B build -G "Visual Studio 17 2022" -A x64- Open
build/alpaca_zorro_plugin.sln - Select configuration: Debug or Release
- Select platform: Win32 or x64
- Press F7 or go to Build → Build Solution
For Debug build:
cmake --build build --config DebugFor Release build:
cmake --build build --config ReleaseAfter successful build, the DLL will be located at:
- Debug:
build/bin/Debug/Alpaca.dll - Release:
build/bin/Release/Alpaca.dll
For Release builds, a distribution package is also created:
build/dist/AlpacaZorroPlugin_<version>.zip
Best for: Development, debugging, and testing
- Configure CMake as described above
- Open the generated solution in Visual Studio
- Build using the IDE
Advantages:
- Full IntelliSense support
- Integrated debugging
- Visual error navigation
- Easy breakpoint management
Best for: CI/CD, automated builds, scripting
# Configure
cmake -B build -G "Visual Studio 17 2022" -A Win32
# Build Debug
cmake --build build --config Debug
# Build Release
cmake --build build --config ReleaseAdvantages:
- Automation friendly
- Faster for batch builds
- No GUI required
Best for: Advanced users, build scripts
# After CMake configuration
msbuild build\alpaca_zorro_plugin.sln /p:Configuration=Release /p:Platform=Win32| Platform | Description | Output Folder | Zorro Plugin Folder |
|---|---|---|---|
| Win32 | 32-bit (x86) build | build/bin/Release/ |
Zorro/Plugin/ |
| x64 | 64-bit build | build/bin/Release/ |
Zorro/Plugin64/ |
| Configuration | Description | Use Case |
|---|---|---|
| Debug | With debug symbols, no optimization | Development, debugging |
| Release | Optimized, no debug info | Production, distribution |
To build both x86 and x64 for both Debug and Release:
# x86 Debug & Release
cmake -B build/x86 -G "Visual Studio 17 2022" -A Win32
cmake --build build/x86 --config Debug
cmake --build build/x86 --config Release
# x64 Debug & Release
cmake -B build/x64 -G "Visual Studio 17 2022" -A x64
cmake --build build/x64 --config Debug
cmake --build build/x64 --config ReleaseSet the ZORRO_ROOT environment variable to automatically copy the built DLL to Zorro's plugin folder:
set ZORRO_ROOT=C:\Zorro
cmake -B build -G "Visual Studio 17 2022" -A Win32
cmake --build build --config Release$env:ZORRO_ROOT="C:\Zorro"
cmake -B build -G "Visual Studio 17 2022" -A Win32
cmake --build build --config Release- Open System Properties → Environment Variables
- Add new User or System variable:
- Name:
ZORRO_ROOT - Value:
C:\Zorro(your Zorro installation path)
- Name:
- Restart your terminal/IDE
When ZORRO_ROOT is set:
- x86 Debug: Copies to
%ZORRO_ROOT%\Plugin\Alpaca.dll - x86 Release: Copies to
%ZORRO_ROOT%\Plugin\Alpaca.dll - x64 Debug: Copies to
%ZORRO_ROOT%\Plugin64\Alpaca.dll - x64 Release: Copies to
%ZORRO_ROOT%\Plugin64\Alpaca.dll
To launch Zorro directly from Visual Studio when debugging:
-
After opening the solution in Visual Studio, create/edit:
alpaca_zorro_plugin.vcxproj.user -
Add the following content:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerCommand>C:\Zorro\Zorro.exe</LocalDebuggerCommand>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerCommand>C:\Zorro\Zorro64\Zorro64.exe</LocalDebuggerCommand>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LocalDebuggerCommand>C:\Zorro\Zorro.exe</LocalDebuggerCommand>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LocalDebuggerCommand>C:\Zorro\Zorro64\Zorro64.exe</LocalDebuggerCommand>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>- Update the paths to match your Zorro installation
Benefits:
- Press F5 to debug with Zorro automatically launching
- Breakpoints work seamlessly
- Full Visual Studio debugging experience
You can customize the build with CMake options:
# Specify build type during configuration
cmake -B build -G "Visual Studio 17 2022" -A Win32 -DCMAKE_BUILD_TYPE=Release
# Verbose build output
cmake --build build --config Release --verbose
# Parallel build (faster)
cmake --build build --config Release --parallel 8To change the output directory:
cmake -B build -G "Visual Studio 17 2022" -A Win32 ^
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY="C:/MyCustomPath"Error: Could not find any instance of Visual Studio.
Solution:
- Install Visual Studio 2022 with C++ Desktop Development workload
- Or specify an older Visual Studio version:
cmake -B build -G "Visual Studio 16 2019" -A Win32
Warning: The intermediate directory contains files shared from another project
Solution: This warning should be fixed in the latest version. If you still see it:
- Delete the
buildfolder - Reconfigure CMake
- Build again
Warning: '>>': shift count negative or too big
Solution: This warning should be suppressed in the latest version of slick_logger included in 3rdparty/slick_logger.
Problem: Can't find Alpaca.dll after building
Solution: Check the correct output folder:
- Debug:
build/bin/Debug/Alpaca.dll - Release:
build/bin/Release/Alpaca.dll
Problem: Can't write to output directory
Solution:
- Close Zorro if it's running (it locks the DLL)
- Run Visual Studio as Administrator
- Check file permissions on the output folder
To perform a clean build:
# Delete build folder
rmdir /s /q build
# Reconfigure and build
cmake -B build -G "Visual Studio 17 2022" -A Win32
cmake --build build --config ReleaseIf you encounter other issues:
- Check the CHANGELOG for known issues
- Search GitHub Issues
- Create a new issue with:
- Your Visual Studio version
- CMake version (
cmake --version) - Full error message
- Build configuration (x86/x64, Debug/Release)
After building, verify the DLL:
# Check DLL exists
dir build\bin\Release\Alpaca.dll
# Check DLL architecture (x86 vs x64)
dumpbin /headers build\bin\Release\Alpaca.dll | findstr machineExpected output:
- x86:
14C machine (x86) - x64:
8664 machine (x64)
After successfully building:
-
Copy
Alpaca.dllto your Zorro plugin folder:- x86:
Zorro/Plugin/Alpaca.dll - x64:
Zorro/Plugin64/Alpaca.dll
- x86:
-
Copy WebSocket Proxy:
- From:
3rdparty/websocket_proxy/bin/ - To: Zorro plugin folder (same as Alpaca.dll)
- From:
-
Configure your Alpaca credentials in Zorro
-
Test with a simple Zorro script
For development workflow and contributing guidelines, see CONTRIBUTING.md