我只是想测试我朋友的代码片段,如下所示:
#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_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 序列号
谁能告诉我出了什么问题?