gpt4 book ai didi

.net - 使用/clr 编译时使用 boost 线程

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:59:25 31 4
gpt4 key购买 nike

我已经放弃直接从 Windows API 创建 GUI,所以我打算使用表单。我想多线程我的应用程序并将 GUI 包装在一个类中并将其放在一个单独的线程中。当我单击按钮等时,它会更改将从主线程读取的结构中的值。我的问题是,当我编译我的应用程序时,链接器出现错误。

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

我的main代码如下。

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;}

在主线程中创建类和调用函数时可以正常工作,但是使用boost会出现问题。我使用正确的编译器 MSVC-10.0 构建了 boost,并且线程库过去一直有效,但 clr 只会导致问题。关于如何解决这个问题的任何建议?或者,如果我应该只使用 .net 多线程(如果我这样做,我真的需要一些关于如何使用 c++ 的链接,我发现的大多数东西都在 C# 中)。谢谢。

最佳答案

在托管应用程序中使用 boost::thread 时有两个问题。第一个是您遇到的链接器错误。如果 boost::thread 实现与您的应用程序静态链接,则第二个是应用程序启动时的初始化错误。

older bug report 中提到了这两个问题.我不知道这在以后的版本中是否有所改变; 1.43有同样的问题。我假设不是因为情况已关闭 wontfix

关于.net - 使用/clr 编译时使用 boost 线程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4649960/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com