C++ Boost.Thread可执行文件无法运行。

huangapple go评论69阅读模式
英文:

c++ boost.thread executable not running

问题

抱歉,以下是您要翻译的内容:

"I'm new to c++ (but not from programing), and I wanted to create a program with thread. I installed boost (https://gist.github.com/zrsmithson/0b72e0cb58d0cb946fc48b5c88511da8) on my computer (windows), but when I run the executable the program just stop (no errors).

The program is the helloworld.cpp program inside the folder example. I think the issue is the lib (-lboost_thread-mgw63-mt-x32-1_66 -lboost_system-mgw63-mt-x32-1_66 -lboost_chrono-mgw63-mt-x32-1_66) or the compiler (MinGW).
The code:

#include <boost/thread/thread.hpp>
#include <iostream>

void helloworld()
{
    std::cout << "Hello World!" << std::endl;
}

int main()
{
    boost::thread thrd(&helloworld);
    thrd.join();
}

Excuse me for my English.
Thank you in advance for your help,
Flayme"

英文:

I'm new to c++ (but not from programing), and I wanted to create a program with thread. I installed boost (https://gist.github.com/zrsmithson/0b72e0cb58d0cb946fc48b5c88511da8) on my computer (windows), but when I run the executable the program just stop (no errors).

The program is the helloworld.cpp program inside the folder example. I think the issue is the lib (-lboost_thread-mgw63-mt-x32-1_66 -lboost_system-mgw63-mt-x32-1_66 -lboost_chrono-mgw63-mt-x32-1_66) or the compiler (MinGW).
The code:

#include <boost/thread/thread.hpp>
#include <iostream>

void helloworld()
{
    std::cout << "Hello World!" << std::endl;
}

int main()
{
    boost::thread thrd(&helloworld);
    thrd.join();
}

Excuse me for my English.
Thank you in advance for your help,
Flayme

答案1

得分: 0

我通过将库放置在编译目录中,并将-L"\MinGW\lib"更改为-L来解决了这个问题。

英文:

I resolved the issue by putting the library inside the folder where I compile, and then changed -L"\MinGW\lib" to -L.

huangapple
  • 本文由 发表于 2023年2月24日 08:00:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/75551483.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定