Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MSVC] fatal error C1189: #error: "This version of XAudio2 is available only in Windows 8 or later. Use the XAudio2 headers and libraries from the DirectX SDK with applications that target Windows 7 and earlier versions." #9968

Closed
Zhaojun-Liu opened this issue Jun 22, 2022 · 6 comments

Comments

@Zhaojun-Liu
Copy link

Issue description:
When I use msvc to build mame under the windows x64 platform, it failed with error like below:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\xaudio2.h(20,1): fatal error C1189: #error: "This version of XAudio2 is available only in Windows 8 or later. Use the XAudio2 headers and libraries from the DirectX SDK with applications that target Windows 7 and earlier versions." [F:\gitP\mamedev\mame\build\projects\windows\mametiny\vs2019\osd_windows.vcxproj]

Could you please help look this issue? Thanks.

Reproduce steps:

  1. git clone https://github.com/mamedev/mame F:\gitP\mamedev\mame
    git -C "F:\gitP\mamedev\mame" rev-parse --git-dir
    git -C "F:\gitP\mamedev\mame" clean -xdf
    git -C "F:\gitP\mamedev\mame" fetch --recurse-submodules=no --force
    git -C "F:\gitP\mamedev\mame" reset --hard 74fe6e9
    git -C "F:\gitP\mamedev\mame" remote prune origin
    git -C "F:\gitP\mamedev\mame" submodule sync
    git -C "F:\gitP\mamedev\mame" submodule foreach git reset --hard
    git -C "F:\gitP\mamedev\mame" submodule foreach git clean -xdf
    git -C "F:\gitP\mamedev\mame" submodule update --init --recursive
  2. set VSCMD_SKIP_SENDTELEMETRY=1 & "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsDevCmd.bat" -host_arch=amd64 -arch=amd64
  3. cd F:\gitP\mamedev\mame
  4. set PATH=F:\gitP\mamedev\mame..\tools\msys64\usr\bin;F:\gitP\mamedev\mame..\tools\msys64\mingw64\bin;%PATH%
  5. make SUBTARGET=tiny PTR64=1 TOOLS=1 OPTIMIZE=0 vs2019 -j4 2>&1
  6. cd F:\gitP\mamedev\mame\build\projects\windows\mametiny\vs2019
    msbuild /m /p:Platform=x64 /p:Configuration=Release /p:WindowsTargetPlatformVersion=10.0.18362.0 /p:PreferredToolArchitecture=x64 mametiny.sln /t:Rebuild

Expected result:
build pass.

Actual result:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\xaudio2.h(20,1): fatal error C1189: #error: "This version of XAudio2 is available only in Windows 8 or later. Use the XAudio2 headers and libraries from the DirectX SDK with applications that target Windows 7 and earlier versions." [F:\gitP\mamedev\mame\build\projects\windows\mametiny\vs2019\osd_windows.vcxproj]

Detailed log:
build.log

@cuavas
Copy link
Member

cuavas commented Jun 25, 2022

This issue is caused by the fact that Microsoft introduced a new version of Xaudio2 with Windows 8 that’s incompatible at the API level with the version included with DirectX for previous versions of Windows. The newer Windows SDKs include the headers and libraries for the new version of Xaudio2, but building an application against this API will make it incompatible with older versions of Windows.

You gt this error because the MAME build scripts currently set the target Windows version to 600 (Windows Vista), but your compiler is finding the newer Xaudio2 header from the Windows SDK rather than the older Xaudio2 header from the DirectX SDK.

You can fix the issue in one of these ways:

  • Add MODERN_WIN_API=1 to the options passed to make when generating the Visual Studio projects. This will set the target Windows version to 602 (Windows 8), allowing you to build against the newer Xaudio2 header from your Windows SDK. However, this may result in the version of MAME you compile being incompatible with Windows 7.
  • Install the DirectX SDK and configure the project to search the DirectX SDK header paths before searching the Windows platform SDK header paths.

@Zhaojun-Liu
Copy link
Author

Zhaojun-Liu commented Jun 27, 2022

Hi @cuavas
Thanks for looking this issue. I tried the first way you said, add MODERN_WIN_API=1 to the options passed to make when generating the Visual Studio projects. it reports error like below:

Error writing output file 'f:\gitP\mamedev\mame\build\generated\resource\mame_tiny_vers.rc': [Errno 2] No such file or directory: 'f:\\gitP\\mamedev\\mame\\build\\generated\\resource\\mame_tiny_vers.rc'
    66>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(145,5): error MSB3073: The command "mkdir "f:\gitP\mamedev\mame\build\generated\mame\tiny\" 2>NUL [F:\gitP\mamedev\mame\build\projects\windows\mametiny\vs2019\mametiny.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(145,5): error MSB3073: @echo Emitting mame_tiny_vers.rc... [F:\gitP\mamedev\mame\build\projects\windows\mametiny\vs2019\mametiny.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(145,5): error MSB3073: python3 "f:\gitP\mamedev\mame\scripts\build\verinfo.py" -f rc -t mame -s tiny -e mametiny -o "f:\gitP\mamedev\mame\build\generated\resource\mame_tiny_vers.rc" -r "f:\gitP\mamedev\mame\scripts\resources\windows\mame\mame.rc" "f:\gitP\mamedev\mame\build\generated\version.cpp" [F:\gitP\mamedev\mame\build\projects\windows\mametiny\vs2019\mametiny.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(145,5): error MSB3073: :VCEnd" exited with code 1. [F:\gitP\mamedev\mame\build\projects\windows\mametiny\vs2019\mametiny.vcxproj]
    66>Done Building Project "F:\gitP\mamedev\mame\build\projects\windows\mametiny\vs2019\mametiny.vcxproj" (Rebuild target(s)) -- FAILED.
     2>Done Building Project "F:\gitP\mamedev\mame\build\projects\windows\mametiny\vs2019\mametiny.vcxproj.metaproj" (Rebuild target(s)) -- FAILED.
     1>Done Building Project "F:\gitP\mamedev\mame\build\projects\windows\mametiny\vs2019\mametiny.sln" (Rebuild target(s)) -- FAILED.

You can check the detailed log:
build.log

Also, I would like to add:
The test machine I use is: windows server 2019.

I updated Mame on June 10th, and the error C1189 started to appear. Before that, the compilation was successful. And also I tried the commit 324f9d4 which is updated at 5/21/2022, the same steps (without option MODERN_WIN_API=1), it also built successfully.

Could you please take a look? Thanks.

@cuavas
Copy link
Member

cuavas commented Jun 27, 2022

I’ll take another look at MSVC project generation after the 0.245 release. The source structure has been reorganised, so things might have changed a bit.

@cuavas
Copy link
Member

cuavas commented Jul 1, 2022

I tested with revision 875ee33.

I used this command to generate Visual Studio projects:

MINGW64=/mingw64 MINGW32= make PYTHON_EXECUTABLE="`which python3.exe`" NOWERROR=1 MODERN_WIN_API=1 NO_USE_PORTAUDIO=1 SUBTARGET=tiny vs2019
  • I’m using an MSYS2 bash shell, you may need to use different syntax to specify environment variables and the location of Python if you’re using a different shell (e.g. Windows NT command prompt).
  • NOWERROR=1 is specified to avoid problems with spurious errors from MSVC about potentially uninitialised local variables.
  • MODERN_WIN_API=1 is specified to target Windows 8 (602) by default, so the XAudio2 header from the platform SDK can be used.
  • NO_USE_PORTAUDIO=1 is specified to avoid an as-yet unresolved issue with duplicate GUIDS being defined by the PortAudio library when the target Windows version is set to Vista (600) or later.
  • I set SUBTARGET=tiny to speed up the build, but this should still use the normal process to build resources.

The build succeeded for me. It’s possible you encountered issues with resource compilation under Visual Studio introduced around 74fe6e9 and fixed in 94c22aa (indirectly caused by bkaradzic/GENie#544).

I added notes about issues affecting compilation with Visual Studio to our documentation in 8d4bbad (see it on our documentation web site here). This should hopefully help people in the future.

@Zhaojun-Liu
Copy link
Author

Ok, thank you for your reply. I will update the commit to 875ee33 and have a try.

@Zhaojun-Liu
Copy link
Author

I tried the commit 875ee33 and specified NOWERROR=1 MODERN_WIN_API=1 NO_USE_PORTAUDIO=1 to generate Visual Studio projects, it built successfully. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants