LoadLibrary 193

后端 未结 2 2104
走了就别回头了
走了就别回头了 2021-02-09 23:55

I am creating a C++/CLI dll that will be loaded into a legacy c++ application. The legacy application does this with a traditional call to LoadLibrary. Both the application and

相关标签:
2条回答
  • 2021-02-10 00:12

    In case anyone runs across this error, it turned out that it was caused by my native libraries use of boost::threading. The boost::threading library uses some weird compilation settings. The result is a static library that is incompatible with clr or mixed-mode binaries. Of course, visual studio has no idea of this, so it happily links boost in and crashes when the dll is loaded.
    The solution is to dynamically link in boost::threading. The easiest way to do this is to define BOOST_THREAD_DYN_LINK in your project settings. Once I defined that, the dll loaded fine.
    A quick google search of C++/CLI boost threading will give plenty more information about this error

    0 讨论(0)
  • 2021-02-10 00:27

    I just has a similar scenario. LoadLibrary failed with 193. My DLL is a managed C++/CLI DLL called from a native application with LoadLibrary.

    However I only get the error on win7 systems. It loads fine on win10. The date of this original question suggests it was win7.

    I narrowed it down to a thread_local class. It appears win7 only supports basic types such as C pointers as thread_local. Anything more complex, even std::shared_ptr which win10 accepts, generates error 193 on Dll load.

    For the record, the compiler is VS2015, and the code style is c++11.

    0 讨论(0)
提交回复
热议问题