Compile error VSTGUI 4.11

Can’t compile over here…

...vstgui4\vstgui\lib\platform\win32\win32directcomposition.cpp(785): error C2365: 'surface': redefinition; previous definition was 'data variable'
...vstgui4\vstgui\lib\platform\win32\win32directcomposition.cpp(785): note: see declaration of 'surface'
...vstgui4\vstgui\lib\platform\win32\win32directcomposition.cpp(786): error C3493: 'surface' cannot be implicitly captured because no default capture mode has been specified

Additionally, it doesn’t look like vstgui.lib is made, but perhaps that a result of the above issue?

A good practice to report such issues is to mention the toolchain you used to compile. So what compiler do you use?

I’m using Visual Studio 2022, but I also tried 2019. I didn’t change any settings in the VS projects. My c++ language is set to: ISO C++17 Standard (/std:c++17) .

You created the visual studio project via the include CMakeLists.txt?

That’s correct.

Hmm, on my machines, on the machines @ Steinberg and on GitHub is building the vstgui library successful. Can you post the full cmake and visual studio build output?

C:\Users\Moe Foe\OneDrive\coding\VST_3_7_5\build>cmake ../vst3sdk
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19043.
-- [SMTG] CMAKE_SOURCE_DIR is set to: C:/Users/Moe Foe/OneDrive/coding/VST_3_7_5/vst3sdk
-- [SMTG] CMAKE_CURRENT_LIST_DIR is set to: C:/Users/Moe Foe/OneDrive/coding/VST_3_7_5/vst3sdk
-- Could NOT find EXPAT (missing: EXPAT_LIBRARY EXPAT_INCLUDE_DIR)
-- VSTGUI will use the embedded Expat package!
-- [SMTG] SMTG_VSTGUI_ROOT is set to: C:/Users/Moe Foe/OneDrive/coding/VST_3_7_5/vst3sdk
-- [SMTG] SMTG_AAX_SDK_PATH is not set. If you need it, please download the AAX SDK!
-- [SMTG] SMTG_MYPLUGINS_SRC_PATH is not set. If you want to add your own Plug-ins folder, specify it!
-- [SMTG] Setup running moduleinfotool for adelay
-- [SMTG] Setup running validator for adelay
-- [SMTG] SMTG_PLUGIN_TARGET_PATH is set to: C:\Users\Moe Foe\AppData\Local\Programs\Common\VST3
-- [SMTG] Setup running moduleinfotool for again
-- [SMTG] Setup running validator for again
-- [SMTG] SMTG_PLUGIN_TARGET_PATH is set to: C:\Users\Moe Foe\AppData\Local\Programs\Common\VST3
-- [SMTG] Setup running moduleinfotool for againsimple
-- [SMTG] Setup running validator for againsimple
-- [SMTG] SMTG_PLUGIN_TARGET_PATH is set to: C:\Users\Moe Foe\AppData\Local\Programs\Common\VST3
-- [SMTG] Setup running moduleinfotool for again-sampleaccurate
-- [SMTG] Setup running validator for again-sampleaccurate
-- [SMTG] SMTG_PLUGIN_TARGET_PATH is set to: C:\Users\Moe Foe\AppData\Local\Programs\Common\VST3
-- [SMTG] Setup running moduleinfotool for channelcontext
-- [SMTG] Setup running validator for channelcontext
-- [SMTG] SMTG_PLUGIN_TARGET_PATH is set to: C:\Users\Moe Foe\AppData\Local\Programs\Common\VST3
-- [SMTG] Setup running moduleinfotool for hostchecker
-- [SMTG] Setup running validator for hostchecker
-- [SMTG] SMTG_PLUGIN_TARGET_PATH is set to: C:\Users\Moe Foe\AppData\Local\Programs\Common\VST3
-- [SMTG] Setup running moduleinfotool for legacymidiccout
-- [SMTG] Setup running validator for legacymidiccout
-- [SMTG] SMTG_PLUGIN_TARGET_PATH is set to: C:\Users\Moe Foe\AppData\Local\Programs\Common\VST3
-- [SMTG] Setup running moduleinfotool for mda-vst3
-- [SMTG] Setup running validator for mda-vst3
-- [SMTG] SMTG_PLUGIN_TARGET_PATH is set to: C:\Users\Moe Foe\AppData\Local\Programs\Common\VST3
-- [SMTG] Setup running moduleinfotool for multiple_programchanges
-- [SMTG] Setup running validator for multiple_programchanges
-- [SMTG] SMTG_PLUGIN_TARGET_PATH is set to: C:\Users\Moe Foe\AppData\Local\Programs\Common\VST3
-- [SMTG] Setup running moduleinfotool for noteexpressionsynth
-- [SMTG] Setup running validator for noteexpressionsynth
-- [SMTG] SMTG_PLUGIN_TARGET_PATH is set to: C:\Users\Moe Foe\AppData\Local\Programs\Common\VST3
-- [SMTG] Setup running moduleinfotool for noteexpressiontext
-- [SMTG] Setup running validator for noteexpressiontext
-- [SMTG] SMTG_PLUGIN_TARGET_PATH is set to: C:\Users\Moe Foe\AppData\Local\Programs\Common\VST3
-- [SMTG] Setup running moduleinfotool for panner
-- [SMTG] Setup running validator for panner
-- [SMTG] SMTG_PLUGIN_TARGET_PATH is set to: C:\Users\Moe Foe\AppData\Local\Programs\Common\VST3
-- [SMTG] Setup running moduleinfotool for pitchnames
-- [SMTG] Setup running validator for pitchnames
-- [SMTG] SMTG_PLUGIN_TARGET_PATH is set to: C:\Users\Moe Foe\AppData\Local\Programs\Common\VST3
-- [SMTG] Setup running moduleinfotool for prefetchable
-- [SMTG] Setup running validator for prefetchable
-- [SMTG] SMTG_PLUGIN_TARGET_PATH is set to: C:\Users\Moe Foe\AppData\Local\Programs\Common\VST3
-- [SMTG] Setup running moduleinfotool for programchange
-- [SMTG] Setup running validator for programchange
-- [SMTG] SMTG_PLUGIN_TARGET_PATH is set to: C:\Users\Moe Foe\AppData\Local\Programs\Common\VST3
-- [SMTG] Setup running moduleinfotool for syncdelay
-- [SMTG] Setup running validator for syncdelay
-- [SMTG] SMTG_PLUGIN_TARGET_PATH is set to: C:\Users\Moe Foe\AppData\Local\Programs\Common\VST3
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/Moe Foe/OneDrive/coding/VST_3_7_5/build

C:\Users\Moe Foe\OneDrive\coding\VST_3_7_5\build>

And here is the output from trying to build AGain.

1>------ Build started: Project: vstgui, Configuration: Debug x64 ------
1>win32directcomposition.cpp
1>C:\Users\Moe Foe\OneDrive\coding\VST_3_7_5\vst3sdk\vstgui4\vstgui\lib\platform\win32\win32directcomposition.cpp(785): error C2365: 'surface': redefinition; previous definition was 'data variable'
1>C:\Users\Moe Foe\OneDrive\coding\VST_3_7_5\vst3sdk\vstgui4\vstgui\lib\platform\win32\win32directcomposition.cpp(785): note: see declaration of 'surface'
1>C:\Users\Moe Foe\OneDrive\coding\VST_3_7_5\vst3sdk\vstgui4\vstgui\lib\platform\win32\win32directcomposition.cpp(786): error C3493: 'surface' cannot be implicitly captured because no default capture mode has been specified
1>Done building project "vstgui.vcxproj" -- FAILED.
2>------ Build started: Project: again, Configuration: Debug x64 ------
2>[SMTG] Copied resource/again.uidesc to C:/Users/Moe Foe/OneDrive/coding/VST_3_7_5/build/VST3/Debug/again.vst3/Contents/Resources
2>[SMTG] Copied resource/background.png to C:/Users/Moe Foe/OneDrive/coding/VST_3_7_5/build/VST3/Debug/again.vst3/Contents/Resources
2>[SMTG] Copied resource/slider_background.png to C:/Users/Moe Foe/OneDrive/coding/VST_3_7_5/build/VST3/Debug/again.vst3/Contents/Resources
2>[SMTG] Copied resource/slider_handle.png to C:/Users/Moe Foe/OneDrive/coding/VST_3_7_5/build/VST3/Debug/again.vst3/Contents/Resources
2>[SMTG] Copied resource/slider_handle_2.0x.png to C:/Users/Moe Foe/OneDrive/coding/VST_3_7_5/build/VST3/Debug/again.vst3/Contents/Resources
2>[SMTG] Copied resource/vu_on.png to C:/Users/Moe Foe/OneDrive/coding/VST_3_7_5/build/VST3/Debug/again.vst3/Contents/Resources
2>[SMTG] Copied resource/vu_off.png to C:/Users/Moe Foe/OneDrive/coding/VST_3_7_5/build/VST3/Debug/again.vst3/Contents/Resources
2>[SMTG] Copied resource/84E8DE5F92554F5396FAE4133C935A18_snapshot.png to C:/Users/Moe Foe/OneDrive/coding/VST_3_7_5/build/VST3/Debug/again.vst3/Contents/Resources/Snapshots
2>[SMTG] Copied resource/84E8DE5F92554F5396FAE4133C935A18_snapshot_2.0x.png to C:/Users/Moe Foe/OneDrive/coding/VST_3_7_5/build/VST3/Debug/again.vst3/Contents/Resources/Snapshots
2>[SMTG] Copied resource/41347FD6FED64094AFBB12B7DBA1D441_snapshot.png to C:/Users/Moe Foe/OneDrive/coding/VST_3_7_5/build/VST3/Debug/again.vst3/Contents/Resources/Snapshots
2>[SMTG] Copied resource/41347FD6FED64094AFBB12B7DBA1D441_snapshot_2.0x.png to C:/Users/Moe Foe/OneDrive/coding/VST_3_7_5/build/VST3/Debug/again.vst3/Contents/Resources/Snapshots
2>LINK : fatal error LNK1104: cannot open file '..\..\..\..\lib\Debug\vstgui.lib'
2>Done building project "again.vcxproj" -- FAILED.
========== Build: 0 succeeded, 2 failed, 10 up-to-date, 0 skipped ==========

Somehow I’m missing the important cmake output. If I run cmake the first lines look like this:

-- Building for: Visual Studio 17 2022
-- The C compiler identification is MSVC 19.32.31329.0
-- The CXX compiler identification is MSVC 19.32.31329.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done

Don’t you get this output?

I cleared my cache and ran cmake again. Maybe its because Windows SDK version 10.0.19043 doesn’t appear to be installed on my system?

C:\Users\Moe Foe\OneDrive\coding\VST_3_7_5\build>cmake -G "Visual Studio 16 2019" ../vst3sdk
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19043.
-- The C compiler identification is MSVC 19.20.27508.1
-- The CXX compiler identification is MSVC 19.20.27508.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.20.27508/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.20.27508/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- [SMTG] CMAKE_SOURCE_DIR is set to: C:/Users/Moe Foe/OneDrive/coding/VST_3_7_5/vst3sdk
-- [SMTG] CMAKE_CURRENT_LIST_DIR is set to: C:/Users/Moe Foe/OneDrive/coding/VST_3_7_5/vst3sdk
-- Could NOT find EXPAT (missing: EXPAT_LIBRARY EXPAT_INCLUDE_DIR)
-- VSTGUI will use the embedded Expat package!
-- [SMTG] SMTG_VSTGUI_ROOT is set to: C:/Users/Moe Foe/OneDrive/coding/VST_3_7_5/vst3sdk
-- [SMTG] SMTG_AAX_SDK_PATH is not set. If you need it, please download the AAX SDK!
-- Performing Test SMTG_USE_STDATOMIC_H
-- Performing Test SMTG_USE_STDATOMIC_H - Failed
-- [SMTG] SMTG_MYPLUGINS_SRC_PATH is not set. If you want to add your own Plug-ins folder, specify it!
-- [SMTG] Setup running moduleinfotool for adelay
-- [SMTG] Setup running validator for adelay
-- [SMTG] SMTG_PLUGIN_TARGET_PATH is set to: C:\Users\Moe Foe\AppData\Local\Programs\Common\VST3
-- [SMTG] Setup running moduleinfotool for again
-- [SMTG] Setup running validator for again
-- [SMTG] SMTG_PLUGIN_TARGET_PATH is set to: C:\Users\Moe Foe\AppData\Local\Programs\Common\VST3
-- [SMTG] Setup running moduleinfotool for againsimple
-- [SMTG] Setup running validator for againsimple
-- [SMTG] SMTG_PLUGIN_TARGET_PATH is set to: C:\Users\Moe Foe\AppData\Local\Programs\Common\VST3
-- [SMTG] Setup running moduleinfotool for again-sampleaccurate
-- [SMTG] Setup running validator for again-sampleaccurate
-- [SMTG] SMTG_PLUGIN_TARGET_PATH is set to: C:\Users\Moe Foe\AppData\Local\Programs\Common\VST3
-- [SMTG] Setup running moduleinfotool for channelcontext
-- [SMTG] Setup running validator for channelcontext
-- [SMTG] SMTG_PLUGIN_TARGET_PATH is set to: C:\Users\Moe Foe\AppData\Local\Programs\Common\VST3
-- [SMTG] Setup running moduleinfotool for hostchecker
-- [SMTG] Setup running validator for hostchecker
-- [SMTG] SMTG_PLUGIN_TARGET_PATH is set to: C:\Users\Moe Foe\AppData\Local\Programs\Common\VST3
-- [SMTG] Setup running moduleinfotool for legacymidiccout
-- [SMTG] Setup running validator for legacymidiccout
-- [SMTG] SMTG_PLUGIN_TARGET_PATH is set to: C:\Users\Moe Foe\AppData\Local\Programs\Common\VST3
-- [SMTG] Setup running moduleinfotool for mda-vst3
-- [SMTG] Setup running validator for mda-vst3
-- [SMTG] SMTG_PLUGIN_TARGET_PATH is set to: C:\Users\Moe Foe\AppData\Local\Programs\Common\VST3
-- [SMTG] Setup running moduleinfotool for multiple_programchanges
-- [SMTG] Setup running validator for multiple_programchanges
-- [SMTG] SMTG_PLUGIN_TARGET_PATH is set to: C:\Users\Moe Foe\AppData\Local\Programs\Common\VST3
-- [SMTG] Setup running moduleinfotool for noteexpressionsynth
-- [SMTG] Setup running validator for noteexpressionsynth
-- [SMTG] SMTG_PLUGIN_TARGET_PATH is set to: C:\Users\Moe Foe\AppData\Local\Programs\Common\VST3
-- [SMTG] Setup running moduleinfotool for noteexpressiontext
-- [SMTG] Setup running validator for noteexpressiontext
-- [SMTG] SMTG_PLUGIN_TARGET_PATH is set to: C:\Users\Moe Foe\AppData\Local\Programs\Common\VST3
-- [SMTG] Setup running moduleinfotool for panner
-- [SMTG] Setup running validator for panner
-- [SMTG] SMTG_PLUGIN_TARGET_PATH is set to: C:\Users\Moe Foe\AppData\Local\Programs\Common\VST3
-- [SMTG] Setup running moduleinfotool for pitchnames
-- [SMTG] Setup running validator for pitchnames
-- [SMTG] SMTG_PLUGIN_TARGET_PATH is set to: C:\Users\Moe Foe\AppData\Local\Programs\Common\VST3
-- [SMTG] Setup running moduleinfotool for prefetchable
-- [SMTG] Setup running validator for prefetchable
-- [SMTG] SMTG_PLUGIN_TARGET_PATH is set to: C:\Users\Moe Foe\AppData\Local\Programs\Common\VST3
-- [SMTG] Setup running moduleinfotool for programchange
-- [SMTG] Setup running validator for programchange
-- [SMTG] SMTG_PLUGIN_TARGET_PATH is set to: C:\Users\Moe Foe\AppData\Local\Programs\Common\VST3
-- [SMTG] Setup running moduleinfotool for syncdelay
-- [SMTG] Setup running validator for syncdelay
-- [SMTG] SMTG_PLUGIN_TARGET_PATH is set to: C:\Users\Moe Foe\AppData\Local\Programs\Common\VST3
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/Moe Foe/OneDrive/coding/VST_3_7_5/build

So I updated my Visual Studio install, deleted my CMakeCache.txt and ran cmake as follows:

cmake -G "Visual Studio 17 2022" ../vst3sdk

After that I was able to properly build vstgui.lib. So it seems like support for VS 2019 has issues.

And just for completeness. I cleared my CMakeCache again and tried to build for VS 2019 once more. And again, the compiler error from the original post pops up.

Are you on the latest version of VS 2019. Again, I’m able to build with the latest VS 2019.

I’m not familiar with using cmake with VS, but in general it’s a good idea to remove CMakeCache,txt when changing the arguments to cmake and regenerating the build environment. In a sandbox checked out from git, another option is to use “git clean” to remove files unknown to git, e.g., "git clean -fX’ or more extensive “git clean -dfX” I believe can remove all cmake generated files (see “git clean help”).

It’s quite possibly out of date. I’ll check tomorrow and let you know if updating does the trick.

Updated and now it works. Sorry for wasting your time.

I’m glad this is solved. But good to know when this pops up again.