stacktrace icon indicating copy to clipboard operation
stacktrace copied to clipboard

Fails to link when using clang compiler under Visual Studio

Open MomoDeve opened this issue 5 years ago • 2 comments

D:\repos\MxEngine\out\build\x64-Clang-Debug\lld-link : error : undefined symbol: DebugCreate
  >>> referenced by D:\boost\boost\stacktrace\detail\frame_msvc.ipp:126
  >>>               MxEngine.lib(Platform.cpp.obj):(private: static void __cdecl boost::stacktrace::detail::debugging_symbols::try_init_com(class boost::stacktrace::detail::com_holder<struct IDebugSymbols> &, class boost::stacktrace::detail::com_global_initer const &))

Fixed by manually including winapi libraries:

#if defined(WIN32)
    #pragma comment(lib, "ole32.lib")
    #pragma comment(lib, "Dbgeng.lib")
#endif
#include <boost/stacktrace.hpp>

MomoDeve avatar Oct 09 '20 11:10 MomoDeve

AFAIK MinGW* and cygwin compilers do not have auto linking support, so #if defined(WIN32) won't work right all the time.

Is there some macro to uniquely identify clang usage on visual studio?

apolukhin avatar Nov 18 '20 19:11 apolukhin

I havent found macro exactly for that, me myself checking it by writing #if defined(__clang__) && defined(_WIN32) Instead of _WIN32 there could also be _MSC_VER, clang sets it for compatibilty with msvc compiler if it was launched using Visual Studio toolchain

MomoDeve avatar Nov 18 '20 20:11 MomoDeve