bombomby / optick

C++ Profiler For Games
https://optick.dev
MIT License
2.95k stars 296 forks source link

Static variable gets declared for every dll it's used in. #71

Closed kadejsan closed 5 years ago

kadejsan commented 5 years ago

https://github.com/bombomby/optick/blob/3ba5d4aa81d1a11f3f33435810fa51b426d17026/src/optick_core.cpp#L413

The problem with those static singletons is that if OPTICK_EVENT(...)s are called from different dll's Optick.exe only picks up the main-thread's one. Is there a way to declare Core and EventDescriptionBoard globally to be shared between different dlls?

bombomby commented 5 years ago

Thanks for the feedback. Sorry, I forgot to mention this particular detail in the documentation. As you've already noticed - you can't use Optick (compiled into a static library) from multiple dynamic libraries.

To fix this problem - there are two options: 1) Move optick's code to one of your common dynamic libraries and add OPTICK_EXPORT define to this dll or 2) Use already precompiled OptickCore.lib + OptickCore.dll supplied in the release package (I've just updated the latest relase with OptickCore.dll).

I've also switched OptickCore project to the dynamic library by default if you need to build shared libraries for other platforms. Feel free to check the updated documentation for more details regarding this issue if needed: https://github.com/bombomby/optick#basic-integration-one-line-of-code