wolfpld / tracy

Frame profiler

Home Page:https://tracy.nereid.pl/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Visual Studio linking issue: cannot find "___tracy_RtlWalkFrameChain" symbol on Windows x64

ditroiaj opened this issue · comments

Hi everyone,

I am currently facing a linking issue with Tracy (tag v0.10, I think the latest at the time of writing) compiled with Visual Studio 2019 (v142) using the VS solution located in library/win32/TracyProfiler.sln. I have a solution, also using Visual Studio 2019 (v142), with multi-DLL project profiling. When compiling my project, I get the following error message: error LNK2001: unresolved external symbol ___tracy_RtlWalkFrameChain. This error appears when I use any call stack-related macro, e.g.: ZoneScopedS(3) in one of my projects. But if I simply use a non-callstack-related Tracy macro, I do not get any issues and the profiling works perfectly.

I first investigated if the symbol is correctly exported in the DLL using the dumpbin /EXPORTS /SYMBOLS TracyProfiler.dll and dumpbin /EXPORTS /SYMBOLS TracyProfiler.lib commands. The symbol was found in both cases.
Output of command dumpbin /exports TracyProfiler.lib:

...
25 18 0001C8D8 ___tracy_RtlWalkFrameChain = ___tracy_RtlWalkFrameChain
...

Output of command dumpbin /exports TracyProfiler.dll:

...
___tracy_RtlWalkFrameChain
...

I also checked several Visual Studio compiler options together:

  1. I checked that both the Configuration (Release) and platform (x64) options were set correctly.
  2. I disabled the Link-Time Code Generation /GL flag, as it is disabled in my projects. Related to that, I explicitly disabled the "Whole Program Optimization" in the project's Property Page > Configuration Properties > Advanced > Whole Program Optimization" and in Property Page > Configuration Properties > C/C++ > Optimization > Whole Program Optimization.
  3. The Runtime Library option is set to /Multi-threaded DLL (/MD) in my projects and TracyProfiler.
  4. The Calling Convention option is set to __cdecl (/Gd) in my projects and TracyProfiler.

Here are other possible root causes that I checked:

  1. Name mangling: The usage of extern "C" is not necessary as it is used everywhere in the Tracy library.
  2. Preprocessor definitions: I added TRACY_CALLSTACK even if it is unnecessary as the required symbol is already exported.

Has anyone ideas for further investigations? Thanks.

Regards.

You probably just forgot TRACY_IMPORTS define in your code that imports the dll.

Thanks, this was the problem.
Marked as closed.