LNK 2019使用Boost::asio时出错
LNK 2019 error using Boost::asio
我只是想测试我朋友的一段代码,如下所示:
#include <boost/asio.hpp>
#include <boost/array.hpp>
#include <iostream>
#include <sstream>
#include <string>
boost::asio::io_service io;
std::string port;
boost::asio::serial_port_base::baud_rate baud(115200);
int main() {
std::cout << "Enter port number: ";
std::getline(std::cin,port);
while(port.empty()) {
std::cout << std::endl;
std::cout << "Error: The user must provide a port number." << std::endl;
std::cout << "Enter port number (Example: COM5): ";
std::getline(std::cin,port);
}
std::cout << std::endl;
return 0;
}
在VC++目录中,我链接了Include和64位库。
在Linker->Input中,我添加了额外的依赖项。
每当我运行此代码时,我都会收到错误:
错误1错误LNK2019:未解析的外部符号"class boost::system::Error_category const&__cdecl boost:;system::system_categor(void)"(?system_category@system@助推@@YAABVerror_category@12@XZ)在函数"public:__thiscall boost::system::error_code::error-code(void)"中引用(??0error_code@system@助推@@QAE@XZ)C:\Users\Bilal\Documents\Visual Studio 2012\Projects\Serial\ Serial\main.obj Serial
和
错误2错误LNK2019:未解析的外部符号"class boost::system::Error_category const&__cdecl boost:;system::generic_categor(void)"(?generic_category@system@助推@@YAABVerror_category@12@XZ)在函数"void __cdecl boost::system::`errno_ecat''(void)的动态初始值设定项"(??__Eerrno_ecat@system@boost@@YAXXZ)C:\Users\Bilal\Documents\Visual Studio 2012\Projects\Serial\main.obj Serial
有人能告诉我出了什么问题吗?
您需要指定库的路径(Linker->其他库目录,然后输入boost库所在的位置),或者将库添加到系统库路径(在linux中)/sys路径(在windows中)。
- 理解boost::asio-async_read在无需读取内容时的行为
- 访问者访问变体并返回不同类型时出错
- 在Linux for Windows上编译C++代码时出错
- 读取文件的最后一行并输入到链接列表时出错
- 提升 ASIO 无法识别计时器对象
- 重载操作程序时出错>>用于类中的字符串 memebr
- 调用专用模板时出错"no matching function for call to [...]"
- C++-试图将函数指针推回到另一个CPP文件中的矢量时出错
- 执行时使用 boost::asio::d eadline_timer 时出错
- 断开连接后重新连接boost beast(asio)websocket和http连接时出错
- 将 std::bind 应用于带有参数 <boost::asio::ip::tcp::socket> 时出错?
- 使用由 Mingw 5.3 编译的 boost ASIO 库使用 QT 时出错
- 在 Cygwin 64 上包含 boost.asio 时出错
- 使用 Boost::asio::async_send_to 发送加密数据时出错
- C2228:TCP asio 服务器出错
- LNK 2019使用Boost::asio时出错
- 编译Boost时出错.Asio示例代码
- 在basic_socket.hpp文件中使用lib boost asio 1.47.0时出错
- 读取文本文件片段并写入boost时出错.asio插座
- 使用Boost Asio时出错