0
votes

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;
}

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:

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

and

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

Can anyone tell me what's going wrong?

1
Make sure you're linking with boost_system.Kerrek SB
If you don't mind explaining, how would I go about doing that? Other than some embedded programming, I don't have much knowledge about these things.user2727300

1 Answers

0
votes

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).