3. building asio tutorial examples (Paul Sutcliffe)
---------- Forwarded message ----------
From: Paul Sutcliffe <psutclif@it.uts.edu.au>
To: boost-users@lists.boost.org
Date: Sun, 10 May 2009 22:17:17 +1000
Subject: [Boost-users] building asio tutorial examples
I'm trying to build the asio tutorial code
http://www.boost.org/doc/libs/1_38_0/doc/html/boost_asio/tutorial.html
Is there a make file anywhere or perhaps a command line example showing exactly what libs are needed?
thanks
Here's a Makefile that I use for building a project with boost::asio libs
BOOST_INCLUDE=/usr/local/include/boost-1_39
BOOST_LIB=/usr/local/lib/boost-1_39
LIBS=/usr/local/lib/libboost_system-gcc42-mt-1_39.so.1.39.0
CC=/usr/bin/g++ #Path to your g++ compler: type 'which g++' to find out
all: serial_test
serial_test: main.o serial_asio.hpp serial_asio.o
$(CC) -I $(BOOST_INCLUDE) -L $(LIBS) main.cpp \
serial_asio.o -lboost_system-gcc40-mt -t -o serial_test
main.o: main.cpp
$(CC) -I $(BOOST_INCLUDE) -c main.cpp -o main.o
serial_asio.o: serial_asio.cpp
$(CC) -I $(BOOST_INCLUDE) -c serial_asio.cpp -o serial_asio.o
clean:
rm -f *.o serial_test
And here's what's in my serial_asio.hpp:
#ifndef SERIAL_ASIO_HPP
#define SERIAL_ASIO_HPP
#include <boost/asio.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/bind.hpp>
#include <boost/asio.hpp>
#include <boost/asio/serial_port.hpp>
#include <string>
#include <iostream>
#include <sstream>
using namespace boost;
using namespace std;
enum { Max_read_length = 256 };
class Serial_connection {
public:
Serial_connection( boost::asio::io_service& io_service );
~Serial_connection();
typedef boost::shared_ptr<Serial_connection> pointer;
static pointer create ( boost::asio::io_service& io_service );
void read_start();
private:
void handle_write ( const boost::system::error_code& an_error,
size_t bytes_transferred );
void handle_read ( const boost::system::error_code& an_error,
size_t bytes_transferred );
boost::asio::serial_port serial_port_;
boost::asio::io_service& io_service_;
char read_msg_[Max_read_length];
boost::asio::streambuf stream_buffer_;
char delimiter_;
stringstream ss_;
bool flip_flop;
};
#endif
If you need more information, I'd be glad to post it here. I think this answers your question regarding "builds".
Regards,
Dave
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users