开发 C++ Boost v1.46.0 链接器问题

发布于 2024-12-03 05:25:48 字数 1745 浏览 1 评论 0原文

我在 Windows XP 上使用 Dev C++,下载了 Boost 包 v 1.46.0 并安装了它。我想用它来创建线程,但我似乎无法编译最简单的代码。

我的代码:

#include <boost/thread.hpp>
using namespace boost; 

void something()
{
}

int main ()
{
    thread rawr = thread(something);
    return 0;
}

编译日志:

.../Dev-Cpp/lib/libboost_thread.a(thread.o)(.text+0x3526):thread.cpp: undefined reference to `gettimeofday'
.../Dev-Cpp/lib/libboost_thread.a(thread.o)(.text+0x3551):thread.cpp: undefined reference to `_gmtime32'
.../Dev-Cpp/lib/libboost_thread.a(thread.o)(.text+0x393e):thread.cpp: undefined reference to `gettimeofday'
.../Dev-Cpp/lib/libboost_thread.a(thread.o)(.text+0x3966):thread.cpp: undefined reference to `_gmtime32'
.../Dev-Cpp/lib/libboost_thread.a(thread.o)(.text+0x3e9e):thread.cpp: undefined reference to `gettimeofday'
.../Dev-Cpp/lib/libboost_thread.a(thread.o)(.text+0x3ec9):thread.cpp: undefined reference to `_gmtime32'

.../Dev-Cpp/lib/libboost_thread.a(thread.o)(.text+0x533a):thread.cpp: undefined reference to `gettimeofday'
.../Dev-Cpp/lib/libboost_thread.a(thread.o)(.text+0x5365):thread.cpp: undefined reference to `_gmtime32'
.../Dev-Cpp/lib/libboost_thread.a(thread.o)(.text+0x57f0):thread.cpp: undefined reference to `gettimeofday'
.../Dev-Cpp/lib/libboost_thread.a(thread.o)(.text+0x581b):thread.cpp: undefined reference to `_gmtime32'
.../Dev-Cpp/lib/libboost_thread.a(thread.o)(.text$_ZN5boost9date_time6c_time6gmtimeEPKlP2tm[boost::date_time::c_time::gmtime(long const*, tm*)]+0x44):thread.cpp: undefined reference to `_gmtime32'
collect2: ld returned 1 exit status

make.exe: *** [project.exe] Error 1

Execution terminated

我在项目选项中链接了 libboost_thread.a 但我想我需要更多东西?(到底是什么?)请帮我解决这个问题。提前致谢 :)

I'm using Dev C++ on Windows XP and I downloaded Boost package v 1.46.0 and installed it. I want to use it to make threads but I can't seem to compile even the simplest code.

My code:

#include <boost/thread.hpp>
using namespace boost; 

void something()
{
}

int main ()
{
    thread rawr = thread(something);
    return 0;
}

Compile log:

.../Dev-Cpp/lib/libboost_thread.a(thread.o)(.text+0x3526):thread.cpp: undefined reference to `gettimeofday'
.../Dev-Cpp/lib/libboost_thread.a(thread.o)(.text+0x3551):thread.cpp: undefined reference to `_gmtime32'
.../Dev-Cpp/lib/libboost_thread.a(thread.o)(.text+0x393e):thread.cpp: undefined reference to `gettimeofday'
.../Dev-Cpp/lib/libboost_thread.a(thread.o)(.text+0x3966):thread.cpp: undefined reference to `_gmtime32'
.../Dev-Cpp/lib/libboost_thread.a(thread.o)(.text+0x3e9e):thread.cpp: undefined reference to `gettimeofday'
.../Dev-Cpp/lib/libboost_thread.a(thread.o)(.text+0x3ec9):thread.cpp: undefined reference to `_gmtime32'

.../Dev-Cpp/lib/libboost_thread.a(thread.o)(.text+0x533a):thread.cpp: undefined reference to `gettimeofday'
.../Dev-Cpp/lib/libboost_thread.a(thread.o)(.text+0x5365):thread.cpp: undefined reference to `_gmtime32'
.../Dev-Cpp/lib/libboost_thread.a(thread.o)(.text+0x57f0):thread.cpp: undefined reference to `gettimeofday'
.../Dev-Cpp/lib/libboost_thread.a(thread.o)(.text+0x581b):thread.cpp: undefined reference to `_gmtime32'
.../Dev-Cpp/lib/libboost_thread.a(thread.o)(.text$_ZN5boost9date_time6c_time6gmtimeEPKlP2tm[boost::date_time::c_time::gmtime(long const*, tm*)]+0x44):thread.cpp: undefined reference to `_gmtime32'
collect2: ld returned 1 exit status

make.exe: *** [project.exe] Error 1

Execution terminated

I linked libboost_thread.a in project options but I guess I need something more?(What exactly?) Please help me fix this. Thanks in advance :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文