使用boost线程使用/ clr编译时线程、boost、clr

2023-09-03 01:44:29 作者:旧爱剩女

我已经放弃了直接从Windows API创建一个图形用户界面,所以我要使用的形式。我想多线程我的应用程序,并包装在一个类中的图形用户界面,并把它放在一个单独的线程。当我点击一个按钮,等,它会改变一个值将被从主线程读取一个结构。我的问题是,当我编译我的应用程序,我得到一个错误的链接。

I have gave up on creating a GUI directly from the windows API so I'm going to use forms. I would like to multithread my app and wrap the GUI in a class and put it in a separate thread. When I click a button, etc, it would change a value in a struct that will be read from the main thread. My problem is, when I compile my application I get an error with the linker.


1>Core.obj : error LNK2022: metadata operation failed (8013119F) : A TypeRef exists which should, but does not, have a corresponding TypeDef: (dummy): (0x0100001f).

我的code为主要如下:

My code for main is as follows.


int main()
{
//create thread object pointer
    boost::thread *GUIThread;
//create pointer to GUIInterface, which contains a member function that
//contains the Application::Run
    GUIInterface *myinterface;
    myinterface = new GUIInterface;

    GUIThread = new boost::thread(boost::bind(&GUIInterface::MainFunction, myinterface));
    return 0;
}

它创建上课的时候​​,并呼吁在主线程的功能,但使用升压工作正常,会导致问题。我建提振使用正确的编译器MSVC-10.0和线程库一直致力于在过去,但CLR只是导致问题。 在任何建议如何解决这一问题? 或者如果我应该只使用.NET多线程(如果我这样做,我真的需要一些链接,如何使用与C ++,大部分的东西,我觉得是在C#)。 谢谢你。

It works fine when creating the class and calling the function in the main thread, but using boost causes problems. I built boost using the correct compiler MSVC-10.0 and the threading library has always worked in the past, but clr just causes problems. Any recommendations on how to fix this? OR if I should just use .net multithreading(if I do, I really need some links to how to use in with c++, most stuff I find is in C#). Thanks.

推荐答案

当有在托管应用程序中使用的boost ::线程有两个问题。第一个是你遇到的连接错误。第二个是初始化错误在应用程序启动时如果的boost ::线程的实施与应用程序静态链接。

There are two problems when using boost::thread in a managed application. The first is the linker error you encountered. The second is an initialization error at application startup if the boost::thread implementation is statically linked with your application.

这两个问题都提到了一个较老的bug报告。我不知道这在以后的版本已经改变,; 1.43有同样的问题。我想不是的情况下被关闭 wontfix

Both problems are mentioned in an older bug report. I don't know if this has changed in later releases; 1.43 has the same problem. I assume not as the case was closed wontfix.