Complete build guide for compiling the native C++ MediaFoundation/WinRT/DirectShow camera capture engine and packaging the Java JAR.
- Windows 10 or 11 (64-bit)
- JDK 17+ (Eclipse Adoptium or Oracle JDK)
- Visual Studio 2022 or 2026 (Community, Professional, or Enterprise) with "Desktop development with C++" workload
- Windows 10/11 SDK (installed with Visual Studio)
- Maven 3.9+
FastCamera includes an automated compilation script with Visual Studio and JDK discovery:
# In the FastCamera repository root:
compile.batWhat compile.bat does automatically:
- Detects Visual Studio 2026 / 2022 Community via
vswhere.exe. - Initializes the 64-bit developer environment (
vcvars64.bat). - Compiles
native/FastCamera.cppwith AVX2 SIMD flags and links MediaFoundation libraries (mfplat.lib,mf.lib,mfreadwrite.lib,mfuuid.lib). - Deploys
fastcamera.dlldirectly to:build/fastcamera.dllsrc/main/resources/native/fastcamera.dll%USERPROFILE%\.fastcore\native\fastcamera\fastcamera.dll
mvn clean install -DskipTestsTo build and execute the official JMH benchmark suite:
run-benchmark.batThe compile.bat script:
- Locates Java JNI headers
- Sets up Visual Studio environment
- Compiles with AVX2 optimizations
- Links MediaFoundation libraries
- Outputs to
build/fastcamera.dll
# Set up Visual Studio environment
call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
# Compile
cl.exe /EHsc /MD /O2 /arch:AVX2 /I"%JAVA_HOME%\include" /I"%JAVA_HOME%\include\win32" \
native\FastCamera.cpp /link /DLL /OUT:fastcamera.dll \
mfplat.lib mf.lib mfreadwrite.lib mfuuid.libmvn clean package # Build JAR
mvn clean package -DskipTests # Skip tests
mvn test # Run testsCopy the built DLL to resources:
copy build\fastcamera.dll src\main\resources\
mvn clean package- Set
JAVA_HOMEenvironment variable - Or run from Developer Command Prompt
- Install Visual Studio 2022 with C++ workload
- Or manually specify path in
compile.bat
- Windows 7: Install Platform Update
- Ensure mfplat.dll is present (Windows 7+)
- Version updated in
pom.xml - Native DLL built and tested
- All unit tests passing
- Example runs successfully
- Git tag created
- GitHub Release with JAR asset