I have a Visual Studio C++ 2017 solution.
The solution has two projects:
my_cpp_project
my_cpp_project_unit_test
I am getting the following error while building the solution:
1>------ Rebuild All started: Project: my_cpp_project, Configuration: Debug x64 ------
1>my_cpp_project.cpp
1>my_cpp_project.vcxproj -> C:\git\my_cpp_project_directory\x64\Debug\my_cpp_project.exe
2>------ Rebuild All started: Project: my_cpp_project_unit_test, Configuration: Debug x64 ------
2>pch.cpp
2>test_autocorrelations.cpp
2>test_energy.cpp
2>Generating Code...
2> Creating library C:\git\my_cpp_project_directory\x64\Debug\my_cpp_project_unit_test.lib and object C:\git\my_cpp_project_directory\x64\Debug\my_cpp_project_unit_test.exp
2>
2>LINK : fatal error LNK1000: Internal error during IMAGE::BuildImage
2>
2> Version 14.16.27051.0
2>
2> ExceptionCode = C0000005
2> ExceptionFlags = 00000000
2> ExceptionAddress = 5829282E (58290000) "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\VCRUNTIME140.dll"
2> NumberParameters = 00000002
2> ExceptionInformation[ 0] = 00000001
2> ExceptionInformation[ 1] = FFBA0000
2>
2>CONTEXT:
2> Eax = 00AF5488 Esp = 003AECA8
2> Ebx = 00AF5408 Ebp = 003AECD4
2> Ecx = 00000080 Esi = 00AF5408
2> Edx = 00000080 Edi = FFBA0000
2> Eip = 5829282E EFlags = 00010247
2> SegCs = 00000023 SegDs = 0000002B
2> SegSs = 0000002B SegEs = 0000002B
2> SegFs = 00000053 SegGs = 0000002B
2> Dr0 = 00000000 Dr3 = 00000000
2> Dr1 = 00000000 Dr6 = 00000000
2> Dr2 = 00000000 Dr7 = 00000000
2>Done building project "my_cpp_project_unit_test.vcxproj" -- FAILED.
========== Rebuild All: 1 succeeded, 1 failed, 0 skipped ==========
How can I resolve this?
So far I have tried:
Disable Precompiled Headers (PCH)
a. Right-click on your project (e.g., surpass_cpp_copy_unit_test) and select Properties.
b. Under C/C++ > Precompiled Headers, change Precompiled Header to Not Using Precompiled Headers.
c. Try rebuilding the solution after this change.
Adjust Linker Settings
a. Open your project properties.
b. Navigate to Linker > Advanced and try changing the Image Has Safe Exception Handlers to No.
c. Alternatively, set the Link Time Code Generation option to Disabled under Linker > Optimization.
Reinstall Toolchain
Those actions didn't resolve the issue.
I have tried various ways to resolve the MSTest-related issue but ultimately failed.
So, I have resolved the issue in an indirect way.
*.vcxproj
file with notepad++
10.0.XXXX
in <WindowsTargetPlatformVersion>10.0.XXXX</WindowsTargetPlatformVersion>
with 8.1
.v142
in <PlatformToolset>v142</PlatformToolset>
with v141
Now, everything is working fine.