【发布时间】:2013-08-28 23:43:05
【问题描述】:
我只是想测试我朋友的一个 sn-p 代码,如下所示:
#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 位库。
在链接器 -> 输入中,我添加了其他依赖项。
每当我运行此代码时,我都会收到错误消息:
错误 1 错误 LNK2019:引用了无法解析的外部符号“class boost::system::error_category const & __cdecl boost::system::system_category(void)”(?system_category@system@boost@@YAABVerror_category@12@XZ)在函数“公共:__thiscall boost::system::error_code::error_code(void)”(??0error_code@system@boost@@QAE@XZ) C:\Users\Bilal\Documents\Visual Studio 2012\Projects\Serial \Serial\main.obj 序列号
和
错误 2 错误 LNK2019:引用了无法解析的外部符号“class boost::system::error_category const & __cdecl boost::system::generic_category(void)”(?generic_category@system@boost@@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\Serial\main.obj 序列号
谁能告诉我怎么回事?
【问题讨论】:
-
确保您与
boost_system链接。 -
如果你不介意解释,我该怎么做呢?除了一些嵌入式编程,我对这些东西了解不多。
标签: c++ boost boost-asio