目录的内容与代码的运行方式混乱,即使没有参考
因此,我花了2个小时试图缩小代码的原因不起作用,我认为这可能只是奇怪的。 我无法将其最小化
// thread example
#include <iostream> // std::cout
#include <thread> // std::thread
void bar()
{
// do stuff...
}
int main()
{
std::cout << "please run" << std::endl;
std::thread t(bar);
t.join();
std::cout << "completed.\n";
return 0;
}
最小
g++ -std=c++0x -o test test.cpp -pthread
这是我拥有的确切示例代码, 非常完美,但是如果我将test.cpp放入项目目录中,请在此处编译并运行它,它甚至在进入MAIN之前就会崩溃。这是崩溃报告,但我从法语中翻译了它,所以这不是确切的文本:
"The entry point of the procedure std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) cannot be found in the library of dynamic links [project directory]\test.exe"
请注意,此消息不是出现在控制台命令中,而是在我无法复制paste的单独窗口中。
这是项目目录的目的(并不完全是因为脚本文件已更新,但它是相同的结构和库): https”> https:> https: //github.com/leroymilo/rtx_cpp
如果有sfml和jsoncpp它改变了一切。
另外,我在Windows10上,如果有任何区别,我正在使用VSCODE。
我做了这篇文章中建议的事情: segmentation' ; 但不会改变结果。
So I spent 2 hours trying to narrow down the cause of my code not working and I think it might just be something weird. Here's the exact example code I have and I can't minimize it further (yes, bar does literally nothing) :
// thread example
#include <iostream> // std::cout
#include <thread> // std::thread
void bar()
{
// do stuff...
}
int main()
{
std::cout << "please run" << std::endl;
std::thread t(bar);
t.join();
std::cout << "completed.\n";
return 0;
}
Here's how I build it :
g++ -std=c++0x -o test test.cpp -pthread
When all of this is done in a blank directory, it works perfectly, but if I put test.cpp in my project directory, compile it here and run it, it crashes before even entering main. Here's the crash report but I translated it from French so it's not the exact text:
"The entry point of the procedure std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) cannot be found in the library of dynamic links [project directory]\test.exe"
Note that this message did not appear in the console command but in a separate window pop-up from where I can't copy-paste.
Here's what's the project directory is (not quite exactly because script files were updated but it's the same structure and libraries) : https://github.com/Leroymilo/RTX_Cpp
It has SFML and jsonCpp in it if it changes anything.
Also I am on Windows10 and I'm using VScode if it makes any difference.
I did what's advised in this post : Segmentation Fault while creating thread using #include<thread> but it does not change the result.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是在我的项目目录中存在一个名为“ libstdc ++ -6.dll”的文件。我对为什么会在这里没有回忆,因为我复制了另一个项目中的所有库,但是如果有人犯同样的错误,请使用您的解决方案。
编辑:我发现了为什么我在文件中有这个问题的原因:这是因为我的构建不是静态的,并且在另一台计算机上启动了构建的可执行文件,显示了一个弹出窗口。我用本文提供的答案解决了我的静态构建问题: libgcc_s_dw2-1.dll和libstdc ++ -6.dll build 的问题。
The issue was the presence of a file called "libstdc++-6.dll" in my project directory. I have no memories of why it's here because I copied all libraries from another project but if anyone does the same mistake, here's your solution.
Edit : I found out about why I had this in my files : it's because my build wasn't static and launching the built executable on another computer showed a pop-up asking for these. I fixed my static build issue with the answers provided in this post : Issues with libgcc_s_dw2-1.dll and libstdc++-6.dll on build .