LoadLibrary 193

后端 未结 2 2103
走了就别回头了
走了就别回头了 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

提交回复
热议问题