So, you already have your code compiling, but you still can't use boost libraries...
There isn't really anything different you need to do, but I'll show you the default values.
C:\MinGW\bin\g++.exe - Location of the C++ Compiler (this works)
C:\MinGW\include\ - Location of the standard C++ header files (this works)
C:\MinGW\include\boost\ - Location of the boost header files (this doesn't work)
Since the include directories already work, you shouldn't need to do anything specific. However, I would check to make sure that the boost folder exists in the include directory and that there are header files in there.
Try this sample code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
#include <string>
#include <iostream>
#include <boost/foreach.hpp>
int main()
{
std::string hello( "Hello, world!" );
BOOST_FOREACH( char ch, hello )
{
std::cout << ch;
}
return 0;
}
|
Before compiling it, make sure this file exists:
C:\MinGW\include\boost\foreach.hpp
If you can locate it (in that exact location), than the code should compile fine. If you locate it and you can't compile it, post the error message here.
Reminder: When using the boost header files, make sure you signify the boost folder before the header file name. This allows the compiler to find the file.
Additional Note: If you use a non header only library (check the boost documentation on their website), you need to include the library that corresponds with the header file. For example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
//
// timer.cpp
// ~~~~~~~~~
//
// 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)
//
#include <iostream>
#include <boost/asio.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
int main()
{
boost::asio::io_service io;
boost::asio::deadline_timer t(io, boost::posix_time::seconds(5));
t.wait();
std::cout << "Hello, world!\n";
return 0;
}
|
boost.asio requires the use of libaries. Since (by default) the C:\MinGW\lib\ directory is already included in the search directories, you simple need to edit the project build options to include the specific library. Simply go to the project's Build Options...(right click on the project name in the project manager and select Build Options...) and then click on the name of the project on the left side of the new window. This sets defaults for both Debug and Release. The next step is to select the Linker Settings tab in the center of the screen. Simply click add then type in the name of the library to be included (minus the lib prefix and the .a extension).
I don't think the recent code has any dependencies upon any libraries, but if you try to compile it and get an error, report back here and post any error messages you get.
I hope this helps you out. Boost libraries are very powerful.