mame icon indicating copy to clipboard operation
mame copied to clipboard

MSVC build failed with error LNK2019: unresolved external symbol PKEY_AudioEngine_DeviceFormat referenced

Open PhoebeHui opened this issue 1 month ago • 5 comments

When I use msvc to build mane with windows x64 platform, it failed with the following two errors:

  1. It emits error 'fatal error RC1015: cannot open include file 'mame.rc' in the first build, I added the '..........\scripts\resources\windows\mame;........\generated\resource;' to "AdditionalIncludeDirectories" in mametiny.vcxproj file, the error has gone.
  2. Afer above error resolved, I encountered the LNK2019 error below. Could you please help take a look?

MAME version

d0f81f8

System information

Windows 11 x64

Incorrect behaviour

C:\gitP\mamedev\mame\build\projects\windows\mametiny\vs2022\mametiny.vcxproj" (Rebuild target) (67) -> (Link target) -> osd_windows.lib(wasapi_sound.obj) : error LNK2019: unresolved external symbol PKEY_AudioEngine_DeviceFormat referenced in function "private: virtual long __cdecl osd::anonymous namespace'::sound_wasapi::OnPropertyValueChanged(wchar_t const *,struct _tagpropertykey)" (?OnPropertyValueChanged@sound_wasapi@?A0x1a050c64@osd@@EEAAJPEB_WU_tagpropertykey@@@Z) [C:\gitP\mamedev\mame\build\projects\windows\mametiny\vs2022\mametiny.vcxproj] osd_windows.lib(xaudio2_sound.obj) : error LNK2001: unresolved external symbol PKEY_AudioEngine_DeviceFormat [C:\gitP\mamedev\mame\build\projects\windows\mametiny\vs2022\mametiny.vcxproj] osd_windows.lib(mmdevice_helpers.obj) : error LNK2001: unresolved external symbol PKEY_AudioEngine_DeviceFormat [C:\gitP\mamedev\mame\build\projects\windows\mametiny\vs2022\mametiny.vcxproj] osd_windows.lib(mmdevice_helpers.obj) : error LNK2019: unresolved external symbol PKEY_AudioEndpoint_PhysicalSpeakers referenced in function "long __cdecl osd::populate_audio_node_info(struct IMMDevice &,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > &,struct osd::audio_info::node_info &)" (?populate_audio_node_info@osd@@YAJAEAUIMMDevice@@AEAV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AEAUnode_info@audio_info@1@@Z) [C:\gitP\mamedev\mame\build\projects\windows\mametiny\vs2022\mametiny.vcxproj] ..\..\..\..\..\mametiny.exe : fatal error LNK1120: 2 unresolved externals [C:\gitP\mamedev\mame\build\projects\windows\mametiny\vs2022\mametiny.vcxproj] osd_windows.lib(wasapi_sound.obj) : error LNK2019: unresolved external symbol PKEY_AudioEngine_DeviceFormat referenced in function "private: virtual long __cdecl osd::anonymous namespace'::sound_wasapi::OnPropertyValueChanged(wchar_t const *,struct _tagpropertykey)" (?OnPropertyValueChanged@sound_wasapi@?A0x1a050c64@osd@@EEAAJPEB_WU_tagpropertykey@@@Z) [C:\gitP\mamedev\mame\build\projects\windows\mametiny\vs2022\mametiny.vcxproj] osd_windows.lib(xaudio2_sound.obj) : error LNK2001: unresolved external symbol PKEY_AudioEngine_DeviceFormat [C:\gitP\mamedev\mame\build\projects\windows\mametiny\vs2022\mametiny.vcxproj] osd_windows.lib(mmdevice_helpers.obj) : error LNK2001: unresolved external symbol PKEY_AudioEngine_DeviceFormat [C:\gitP\mamedev\mame\build\projects\windows\mametiny\vs2022\mametiny.vcxproj] osd_windows.lib(mmdevice_helpers.obj) : error LNK2019: unresolved external symbol PKEY_AudioEndpoint_PhysicalSpeakers referenced in function "long __cdecl osd::populate_audio_node_info(struct IMMDevice &,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > &,struct osd::audio_info::node_info &)" (?populate_audio_node_info@osd@@YAJAEAUIMMDevice@@AEAV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AEAUnode_info@audio_info@1@@Z) [C:\gitP\mamedev\mame\build\projects\windows\mametiny\vs2022\mametiny.vcxproj] ..........\mametiny.exe : fatal error LNK1120: 2 unresolved externals [C:\gitP\mamedev\mame\build\projects\windows\mametiny\vs2022\mametiny.vcxproj]

Expected behaviour

It build successfully.

Steps to reproduce

  1. git clone https://github.com/mamedev/mame C:\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 d0f81f8 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\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" -host_arch=amd64 -arch=amd64 -winsdk=10.0.26100.0
  3. cd /d C:\gitP\mamedev\mame
  4. set PATH=C:\tools\msys64\usr\bin;C:\tools\msys64\mingw64\bin;%PATH%
  5. make SUBTARGET=tiny PTR64=1 TOOLS=1 OPTIMIZE=0 NOWERROR=1 MODERN_WIN_API=1 NO_USE_PORTAUDIO=1 vs2022 -j4
  6. cd /d C:\gitP\mamedev\mame\build\projects\windows\mametiny\vs2022
  7. msbuild /m /p:Platform=x64 /p:Configuration=Release /p:PreferredToolArchitecture=x64 mametiny.sln /t:Rebuild

Build.log

PhoebeHui avatar Oct 30 '25 08:10 PhoebeHui

Builds fine for me if I exclude NO_USE_PORTAUDIO=1 (I also used MSBUILD=1 instead of the manual invocation). I suggest the instruction to exclude PortAudio for MSVC builds is no longer necessary.

pmackinlay avatar Oct 31 '25 01:10 pmackinlay

Hi @pmackinlay, thank you for your response!

I removed 'NO_USE_PORTAUDIO=1', and execute make SUBTARGET=tiny PTR64=1 TOOLS=1 OPTIMIZE=0 NOWERROR=1 MODERN_WIN_API=1 MSBUILD=1 vs2022 -j4, it failed with '........\generated\resource\mame_tiny_vers.rc(41): fatal error RC1015: cannot open include file 'mame.rc'. [C:\gitP\mamedev\mame\build\projects\windows\mametiny\vs2022\mametiny.vcxproj]' have you encounterred this issue?

I added the '..........\scripts\resources\windows\mame;........\generated\resource;' to "AdditionalIncludeDirectories" in mametiny.vcxproj file, the issue has gone.

Then I rebuild the project, and it builds successfully! Remove NO_USE_PORTAUDIO=1 fixing the Link error.

PhoebeHui avatar Oct 31 '25 03:10 PhoebeHui

try adding REGENIE=1 to your make command

grant2258 avatar Nov 03 '25 18:11 grant2258

hi @grant2258, after I add REGENIE=1 to make command, the error ''........\generated\resource\mame_tiny_vers.rc(41): fatal error RC1015: cannot open include file 'mame.rc'.' still persists.

PhoebeHui avatar Nov 05 '25 08:11 PhoebeHui

Not sure why its doing that was worth a try. Maybe someone that knows the build system better can get to the bottom of if.

grant2258 avatar Nov 05 '25 11:11 grant2258