使用Boost :: asio的LNK 2019错误 [英] LNK 2019 error using Boost::asio
问题描述
我只是想测试我的朋友代码片段,就像这样:
I am just trying to test a snippet of my friends code which goes like:
#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 ++目录中,我已经链接了包括库和64位库.
In the VC++ directories I have linked both the Include and the 64 bit libraries.
在链接器->输入中,我添加了其他依赖项.
In Linker -> Input I have put additional dependencies.
每当我运行此代码时,都会出现错误:
Whenever I run this code I get the error:
错误1错误LNK2019:无法解析的外部符号类boost :: system :: error_category const& __cdecl boost :: system :: system_category(void)"(?system_category @ system @ boost @@ YAABVerror_category @ 12 @ XZ)在函数"public:__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串行
Error 1 error LNK2019: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category@system@boost@@YAABVerror_category@12@XZ) referenced in function "public: __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 Serial
和
错误2错误LNK2019:未解析的外部符号类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序列
Error 2 error LNK2019: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category@system@boost@@YAABVerror_category@12@XZ) referenced in function "void __cdecl boost::system::`dynamic initializer for 'errno_ecat''(void)" (??__Eerrno_ecat@system@boost@@YAXXZ) C:\Users\Bilal\Documents\Visual Studio 2012\Projects\Serial\Serial\main.obj Serial
谁能告诉我怎么了?
推荐答案
您需要指定lib的路径(Linker->其他库目录,然后输入boost lib所在的位置),或将库添加到系统库中路径(在Linux中)/sys路径(在Windows中).
You need specify the path of the lib(Linker->additional library directories, then input where your boost lib is), or add the library to the system library path(in linux)/sys path(in windows).
这篇关于使用Boost :: asio的LNK 2019错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!