This is the coda, all of it. Is it possible that I am running only one part of the full example?
http://www.boost.org/doc/libs/1_49_0/doc/html/boost_asio/examples.html (http://www.boost.org/doc/libs/1_49_0/doc/html/boost_asio/examples.html) Chat example.
//
// chat_message.hpp
// ~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef CHAT_MESSAGE_HPP
#define CHAT_MESSAGE_HPP
#include <boost/asio.hpp>
#include <cstdio>
#include <cstdlib>
#include <cstring>
class chat_message
{
public:
enum { header_length = 4 };
enum { max_body_length = 512 };
chat_message()
: body_length_(0)
{
}
const char* data() const
{
return data_;
}
char* data()
{
return data_;
}
size_t length() const
{
return header_length + body_length_;
}
const char* body() const
{
return data_ + header_length;
}
char* body()
{
return data_ + header_length;
}
size_t body_length() const
{
return body_length_;
}
void body_length(size_t new_length)
{
body_length_ = new_length;
if (body_length_ > max_body_length)
body_length_ = max_body_length;
}
bool decode_header()
{
using namespace std; // For strncat and atoi.
char header[header_length + 1] = "";
strncat(header, data_, header_length);
body_length_ = atoi(header);
if (body_length_ > max_body_length)
{
body_length_ = 0;
return false;
}
return true;
}
void encode_header()
{
using namespace std; // For sprintf and memcpy.
char header[header_length + 1] = "";
sprintf(header, "%4d", body_length_);
memcpy(data_, header, header_length);
}
private:
char data_[header_length + max_body_length];
size_t body_length_;
};
#endif // CHAT_MESSAGE_HPP
From what I can tell, you did not add the libraries previously mentioned to your linker.
The ones you need are system (most likely named something similar to boost_system-mgw44-mt-1_49) and ws2_32.
See here (http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_(general)#Q:_I_would_like_to_compile_a_project_using_some_non-standard_libraries._How_can_I_indicate_to_CodeBlocks_that_these_libraries_and_include_files_exist.3F) if you do not know how to add libraries.
For future reference, that is not a full build log. A full build log would look something like this. (See my previous link for how to enable full command line logging.)
-------------- Build: Release in Hello ---------------
mingw32-g++.exe -Wall -fexceptions -Os -c "C:\Documents and Settings\Alpha\My Documents\Programing\Hello\main.cpp" -o obj\Release\main.o
mingw32-g++.exe -o bin\Release\Hello.exe obj\Release\main.o -s
Output size is 7.00 KB
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings (0 minutes, 0 seconds)