使用QT使用Mingw 5.3编译的boost ASIO库出错
Error Using boost ASIO library compiled by Mingw 5.3 using QT
我使用这个命令使用 QT5.10.0 自带的 Mingw 5.3 编译了 boost 库
bootstrap gcc
b2 toolset=gcc
然后我测试了它的一些库作为日期时间和文件系统,它运行良好。现在我想尝试使用网络库 asio,所以我 link 使用 QT 编辑了该库,通过右键单击项目添加库 -> 添加库 我添加了那些
boost.regex
boost.system
boost.thread
boost.date_time
boost 文档中提到 link 该库使用 asio 库 here
当我制作一个仅包含 header
的简单 hello world 应用程序时出现此错误
#include <boost/asio.hpp>
编译时出现此错误。
D:\Build\boost_1_66_0\stage\lib\libboost_system-mgw53-mt-x32-1_66.a(error_code.o):-1: error: duplicate section `.rdata$_ZTIN5boost6system14error_category12std_categoryE[__ZTIN5boost6system14error_category12std_categoryE]' has different size
D:\Build\boost_1_66_0\stage\lib\libboost_system-mgw53-mt-x32-1_66.a(error_code.o):-1: error: duplicate section `.rdata$_ZTVN5boost6system14error_category12std_categoryE[__ZTVN5boost6system14error_category12std_categoryE]' has different size
: error: undefined reference to `_imp__WSACleanup@0'
: error: undefined reference to `_imp__WSAStartup@8'
: error: ld returned 1 exit status
在使用 QT 附带的 Mingw 5.3.0 完成编译 boost 库后,我也遇到了一些失败和跳过的问题。所以我不知道这些是否会影响我使用 asio 的构建,我单独测试每个库,例如需要系统库的日期和时间正则表达式和文件系统,并且都可以正常工作。但是boost线程给了我重复部分的错误,比如上面的错误
提前致谢
您需要为 Windows 构建一些额外的库。
尝试将以下行添加到您的 .pro
文件中:
LIBS += -lgdi32
LIBS += -lwsock32
LIBS += -lws2_32
有几个 .pro
文件在 Windows
上构建 boost asio
HTTP 服务器和客户端,MinGw 5.3
来自 Qt
here .
我使用这个命令使用 QT5.10.0 自带的 Mingw 5.3 编译了 boost 库
bootstrap gcc
b2 toolset=gcc
然后我测试了它的一些库作为日期时间和文件系统,它运行良好。现在我想尝试使用网络库 asio,所以我 link 使用 QT 编辑了该库,通过右键单击项目添加库 -> 添加库 我添加了那些
boost.regex
boost.system
boost.thread
boost.date_time
boost 文档中提到 link 该库使用 asio 库 here 当我制作一个仅包含 header
的简单 hello world 应用程序时出现此错误#include <boost/asio.hpp>
编译时出现此错误。
D:\Build\boost_1_66_0\stage\lib\libboost_system-mgw53-mt-x32-1_66.a(error_code.o):-1: error: duplicate section `.rdata$_ZTIN5boost6system14error_category12std_categoryE[__ZTIN5boost6system14error_category12std_categoryE]' has different size
D:\Build\boost_1_66_0\stage\lib\libboost_system-mgw53-mt-x32-1_66.a(error_code.o):-1: error: duplicate section `.rdata$_ZTVN5boost6system14error_category12std_categoryE[__ZTVN5boost6system14error_category12std_categoryE]' has different size
: error: undefined reference to `_imp__WSACleanup@0'
: error: undefined reference to `_imp__WSAStartup@8'
: error: ld returned 1 exit status
在使用 QT 附带的 Mingw 5.3.0 完成编译 boost 库后,我也遇到了一些失败和跳过的问题。所以我不知道这些是否会影响我使用 asio 的构建,我单独测试每个库,例如需要系统库的日期和时间正则表达式和文件系统,并且都可以正常工作。但是boost线程给了我重复部分的错误,比如上面的错误 提前致谢
您需要为 Windows 构建一些额外的库。
尝试将以下行添加到您的 .pro
文件中:
LIBS += -lgdi32
LIBS += -lwsock32
LIBS += -lws2_32
有几个 .pro
文件在 Windows
上构建 boost asio
HTTP 服务器和客户端,MinGw 5.3
来自 Qt
here .