tyoma / micro-profiler

Cross-platform low-footprint realtime C/C++ Profiler
https://visualstudiogallery.msdn.microsoft.com/133d5764-b32b-4ec9-8ee8-5546eca64584
MIT License
242 stars 28 forks source link

Unable to link project after Enable Profiling (VS2019 community) #82

Open DiscipleOfEris opened 1 year ago

DiscipleOfEris commented 1 year ago

This is very similar to the (closed) issue #31, but for Visual Studio 2019 community edition. It's for a large x64 project.

I have installed the micro-profiler extension. However, when I Enable Profiling (with the checkmark now visible) and recompile, the linker fails. I get one warning and three errors (two of which are repeated multiple times).

Warning LNK4044 unrecognized option '/micro-profiler_x64.lib'; ignored
Error   LNK2001 unresolved external symbol _penter
Error   LNK2001 unresolved external symbol _pexit
Error   LNK1120 2 unresolved externals

The LNK4044 warning and LNK1120 error each happen once. The two LNK2001 errors comprise the remaining 520 errors (for each .obj file the linker tries to resolve), for a total of 1 warning and 521 errors.

It seems to me that $(MICROPROFILERDIR)/micro-profiler_$(PlatformName).lib in the Project Properties > Linker > Input > Additional Dependencies setting is being resolved as /micro-profiler_x64.lib, rather than pointing to an actual directory. My initial guess is that this is where the problem lies.

image

For information completeness, the /GH /Gh flags were automatically added by the Enable Profiling button as well.

image

The project is able to compile fine when I uncheck the Enable Profiling option.

tyoma commented 1 year ago

@DiscipleOfEris did VS restart help you? Unfortunately, my fix with simple termination of the spawn MSBuild.exe doesn't help - the environment variables are not getting set for the restarted MSBuild instances. The only safe solution (as of now) is to restart VisualStudio - then the MICROPROFILERDIR variable gets set and the new instance of VisualStudio will build fine.

DiscipleOfEris commented 1 year ago

@tyoma I did restart VS to no avail, but an additional restart of my computer seemed to to the trick.