I have a simple C project which warps a x64 MASM project. When this builds in Release configuration the resulting dll still references VCRUNTIME140D.dll
and VCRUNTIME140_1D.dll
which I understand are debug versions of the runtime. This is causing a The specified module could not be found. (0x8007007E)
error when run on a machine with the normal runtime installed.
What do I need to change to build against the release runtime?
The definition group for Release|x64
looks like this:
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>EMULATORCODE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<Optimization>Disabled</Optimization>
<RemoveUnreferencedCodeData>false</RemoveUnreferencedCodeData>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>false</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
<CustomBuild>
<Command>echo</Command>
</CustomBuild>
</ItemDefinitionGroup>
With the commandline msbuild "EmulatorCore.vcxproj" /p:configuration=Release /p:platform=x64
, the output is as follows:
MSBuild version 17.8.5+b5265ef37 for .NET Framework
Build started 11/05/2024 15:27:41.
Project "EmulatorCore.vcxproj" on node 1 (default targets).
PrepareForBuild:
Structured output is enabled. The formatting of compiler diagnostics will reflect the error hierarchy. See https://aka.ms/cpp/structured-output for more details.
InitializeBuildStatus:
Creating "x64ReleaseEmulatorCore.tlogunsuccessfulbuild" because "AlwaysCreate" was specified.
Touching "x64ReleaseEmulatorCore.tlogunsuccessfulbuild".
CustomBuild:
Performing Custom Build Tools
Microsoft (R) Macro Assembler (x64) Version 14.38.33134.0
Copyright (C) Microsoft Corporation. All rights reserved.
Assembling: core.asm
ClCompile:
C:Program FilesMicrosoft Visual Studio2022CommunityVCToolsMSVC14.38.33130binHostX64x64CL.exe /c /Zi /nologo /W3 /WX- /diagnostics:column /sdl /Od /Oi /GL /D EMULATORCODE_EXPORTS /D _WINDOWS /D _USRDLL /D _WINDLL /D _UNICODE /D UNICODE /Gm- /EHsc /MD /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /pe
rmissive- /Yc"pch.h" /Fp"x64ReleaseEmulatorCore.pch" /Fo"x64Release\" /Fd"x64Releasevc143.pdb" /external:W3 /Gd /TP /FC /errorReport:queue pch.cpp
pch.cpp
C:Program FilesMicrosoft Visual Studio2022CommunityVCToolsMSVC14.38.33130binHostX64x64CL.exe /c /Zi /nologo /W3 /WX- /diagnostics:column /sdl /Od /Oi /GL /D EMULATORCODE_EXPORTS /D _WINDOWS /D _USRDLL /D _WINDLL /D _UNICODE /D UNICODE /Gm- /EHsc /MD /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /pe
rmissive- /Yu"pch.h" /Fp"x64ReleaseEmulatorCore.pch" /Fo"x64Release\" /Fd"x64Releasevc143.pdb" /external:W3 /Gd /TP /FC /errorReport:queue EmulatorCore.cpp dllmain.cpp ym_wrapper.cpp
EmulatorCore.cpp
dllmain.cpp
ym_wrapper.cpp
Link:
C:Program FilesMicrosoft Visual Studio2022CommunityVCToolsMSVC14.38.33130binHostX64x64link.exe /ERRORREPORT:QUEUE /OUT:"x64ReleaseEmulatorCore.dll" /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
/MANIFEST /MANIFESTUAC:NO /manifest:embed /PDB:"x64ReleaseEmulatorCore.pdb" /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /LTCG:incremental /LTCGOUT:"x64ReleaseEmulatorCore.iobj" /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"x64ReleaseEmulatorCore.lib" /MACHINE:X64 /DLL x64Releasecore.obj
x64Releasedllmain.obj
x64ReleaseEmulatorCore.obj
x64Releasepch.obj
x64Releaseym_wrapper.obj
Creating library x64ReleaseEmulatorCore.lib and object x64ReleaseEmulatorCore.exp
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library [EmulatorCore.vcxproj]
Generating code
Previous IPDB not found, fall back to full compilation.
All 317 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
Finished generating code
EmulatorCore.vcxproj -> x64ReleaseEmulatorCore.dll
FinalizeBuildStatus:
Deleting file "x64ReleaseEmulatorCore.tlogunsuccessfulbuild".
Touching "x64ReleaseEmulatorCore.tlogEmulatorCore.lastbuildstate".
Done Building Project "EmulatorCore.vcxproj" (default targets).
But I still get the debug dependencies:
Microsoft (R) COFF/PE Dumper Version 14.38.33134.0
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file emulatorcore.dll
File Type: DLL
Image has the following dependencies:
MSVCP140.dll
VCRUNTIME140_1D.dll
VCRUNTIME140D.dll
ucrtbased.dll
KERNEL32.dll