Reputation: 6213
Simply try to build code copied and pasted from a Boost tutorial. (see below)
I have the header only file, no built libraries as of yet.
Problem is I am getting two errors:
Error 1 error LNK1104: cannot open file 'libboost_system-vc100-mt-gd-1_53.lib' \\selafap01\homedrives\mgibson\My Documents\Visual Studio 2010\Projects\C++ Boost Test\C++ Boost Test\LINK C++ Boost Test
2 IntelliSense: #error directive: "Incompatible build options" c:\boost\config\auto_link.hpp 111 4
Regardless of what I do it seems to want a .lib file, which I don't really know how to do.
#include <boost/asio.hpp>
class SimpleSerial
{
public:
/**
* Constructor.
* \param port device name, example "/dev/ttyUSB0" or "COM4"
* \param baud_rate communication speed, example 9600 or 115200
* \throws boost::system::system_error if cannot open the
* serial device
*/
SimpleSerial(std::string port, unsigned int baud_rate)
: io(), serial(io,port)
{
serial.set_option(boost::asio::serial_port_base::baud_rate(baud_rate));
}
/**
* Write a string to the serial device.
* \param s string to write
* \throws boost::system::system_error on failure
*/
void writeString(std::string s)
{
boost::asio::write(serial,boost::asio::buffer(s.c_str(),s.size()));
}
/**
* Blocks until a line is received from the serial device.
* Eventual '\n' or '\r\n' characters at the end of the string are removed.
* \return a string containing the received line
* \throws boost::system::system_error on failure
*/
std::string readLine()
{
//Reading data char by char, code is optimized for simplicity, not speed
using namespace boost;
char c;
std::string result;
for(;;)
{
asio::read(serial,asio::buffer(&c,1));
switch(c)
{
case '\r':
break;
case '\n':
return result;
default:
result+=c;
}
}
}
private:
boost::asio::io_service io;
boost::asio::serial_port serial;
};
Any direction on how to get that lib file as it really doesn't seem to be in the Boost header only directory anywhere, computer search doesn't find anything either.. would be very appreciated.
Cheers
EDIT 1:
Was able to generate the .lib file that was neccessary but navigating the boost directory in Visual Studio command prompt and running bootstrap.bat, this generate b2.exe, I ran that and the stage/lib directory was generated with the needed binaries.
However, now I am getting another error.. "error LNK1561: entry point must be defined"
I guess the circle of errors goes on :)
EDIT 2: The entry point being referred to was main(). Forgot the main! Oh well, added in a main and all is well!
Upvotes: 0
Views: 4769
Reputation: 71
In my case Release mode runs well, but Debug mode show this error...
Try this: Right click on the project in VStudio Properties -> C/C++ -> Code General -> Runtime Library : change /MT to /MTD.
Upvotes: 0
Reputation: 1927
You will need to install boost and have the libraries present if you're doing a static link in your build. Once installed, you will be able to find and specify the path to the libraries as part of your VS project configuration.
Upvotes: 0
Reputation: 1287
For the first error: rightclick on the project in VStudio -> Properties -> Linker ->General -> Additional Library Directories "boost\stage\lib" it seems that you tried to link the wrong folder. Also check that the file
libboost_system-vc100-mt-gd-1_53.lib
is in the boost\stage\lib folder.
Upvotes: 3