1 of 12
http://forums.codeblocks.org/index.php?topic=15164.0
Code::Blocks
Search
Login
Home
Help
Search
Login
Register
News:
The new Release 13.12 is out! You can download binaries
for windows, mac and many major linux distros from
http://www.codeblocks.org/downloads/26 .
Wiki
previous next
Pages: [1] 2 All
Author
Go Down
aaronds
Newcomer
Posts: 5
Hi,
I've never configured an external library with a C/C++ IDE before so this is
all new to me. I'm looking to configure the Boost library with Code::Blocks
(windows, MinGW) but I just can't get it working. I have built and installed
the Boost library, I just need to configure it with my project. I have of
course consulted the documentation but it appears to be some what out of
date, as it uses Boost 1.42 (I'm using 1.47). The documentation talks about
include and lib folders, neither of which are in my installation.
So far, I have set up a global variable in the IDE called "boost" that links to
the base directory of the boost installation as the base field (under builtin
fields) and links to the boost/ subdirectory as the include field. Within the
build options for my project, under search directories, I have set the
compiler directory to the boost subdirectory within the boost installation
folder, while I have also set the linker directory to the stage folder.
However, I am aware that even if all that I have done so far is correct, I still
need to add additional linker settings but I'm lost as to what to do here.
From what I can make out in the documentation I need to link specific
libraries (I'm trying to use the asio library within Boost), but I can't find
anything relevent within my boost installation.
If anyone could tell me whether what I've done so far is correct or not and
perhaps direct me on where I should go from here, I would be very
appreciative.
Cheers
Logged
Alpha
Developer
Lives here!
It sounds like you have done most everything correctly so far, but just in
case, I will list out several steps.
2/26/2015 7:52 PM
2 of 12
Posts: 1442
http://forums.codeblocks.org/index.php?topic=15164.0
Create the global variable boost with extract_dir as the base. (This is
C:\Libraries\boost_1_47_0 on my computer.) The other fields do not need
anything (except possibly lib; if you used a custom directory while building
boost, put the path here).
Next (assuming you are starting a project, not adding to an existing one),
create a new project (a console app should be fine; see this page if you need
step-by-step instructions on that).
In this project, open Project->Build options... and ensure that the overall
name of the project is selected in the left-hand column (for example,
boost_test). Switch to the Search directories tab and click Add (for the
Compiler tab). In the box, type $(#boost) and click OK.
Many features of boost do not require any libraries, (asio included). Here is
a list of what does require linking.
(Edit:) Asio depends on Boost.System and may need Boost.Regex and
OpenSSL depending on what you are doing.
To test the current configuration, put this (from here) in the main cpp.
Code: [Select]
#include <boost/lambda/lambda.hpp>
#include <iostream>
#include <iterator>
#include <algorithm>
int main()
{
using namespace boost::lambda;
typedef std::istream_iterator<int> in;
std::for_each(
in(std::cin), in(), std::cout << (_1 * 3) << " " );
}
aaronds
Newcomer
Logged
Posts: 5
My boost installation doesn't have a lib folder (maybe I'm getting the wrong
idea)? I've done everything you said and I'm currently getting the undefined
2/26/2015 7:52 PM
3 of 12
http://forums.codeblocks.org/index.php?topic=15164.0
reference errors you talked about. In order to check whether this was due to
a linker error, I linked all the available libraries (from the stage folder) but
the errors persist (they're coming from error_code.hpp). Really not sure why
I haven't been able to resolve this :S
Thanks again
Last Edit: August 24, 2011, 10:17:43 pm by aaronds
Alpha
Developer
Lives here!
Logged
I assume from this the build succeded, so there should be multiple lib*.a
files somewhere on your harddrive - the default folder is lib, however, it
seems they have gone somewhere else on your computer. Locate this folder
and add it to the linker search directories.
Logged
aaronds
Newcomer
Posts: 5
Quote from: Alpha on August 25, 2011, 12:20:10 am
Did the minimal code sample I provided compile?
The code example appears to compile, but it doesn't output anything to the
CMD window (it just seems to hang...?).
Quote from: Alpha on August 25, 2011, 12:20:10 am
I assume from this the build succeded, so there should be multiple lib*.a files somewhere on
your harddrive - the default folder is lib, however, it seems they have gone somewhere else
on your computer. Locate this folder and add it to the linker search directories.
I have a range of .lib files but not .a. When I built boost I didn't receive any
errors and as far as I know the build was successful. However, I don't have a
/lib/ folder, only /libs/ and /stage/lib/. I believe the output of the build was
to /boost/bin.v2/libs (all directories created during the build). I didn't see
anything else created. Maybe this is where the problem is...?
Logged
Alpha
Developer
Lives here!
2/26/2015 7:52 PM
4 of 12
http://forums.codeblocks.org/index.php?topic=15164.0
The code example appears to compile, but it doesn't output anything to the CMD window (it
just seems to hang...?).
Oh, I should have mentioned all it does is multiply the input number by 3
(you need to type a number and press enter).
Posts: 1442
aaronds
Newcomer
Logged
Posts: 5
Hi, I've just rebuilt boost and it looks a bit more promising. I hadn't
configured the build to compile with MinGW previously (it had still built
though). I'll edit once I try to build a project.
Quote from: Alpha on August 25, 2011, 03:05:56 am
Quote from: aaronds on August 25, 2011, 01:03:40 am
2/26/2015 7:52 PM
5 of 12
http://forums.codeblocks.org/index.php?topic=15164.0
The code example appears to compile, but it doesn't output anything to the CMD
window (it just seems to hang...?).
Oh, I should have mentioned all it does is multiply the input number by 3 (you need to type a
number and press enter).
Both errors originate from winsock_init.ipp. I've tried linking a few libraries
(this time I have the .a files, one of the libs I tried linking was system) but I
haven't resolved the issue.
Quote from: Alpha on August 24, 2011, 07:00:35 pm
If in working you ever come up with an undefined reference error, it will usually indicate a
library does need to be linked. In this case, return to the main project's search directories
settings, but this time on the Linker tab. Add $(#boost)\lib (or $(#boost.lib) if you set
up the lib variable); this should point to the directory with all the lib*.a files.
After this, go to the Linker settings tab and add (using the Add button of course) the needed
library or libraries. (For example, boost_filesystem for the Boost.Filesystem library basically the name of the file minus the lib and the .a.)
Alpha
Developer
Lives here!
Logged
Posts: 1442
Both errors originate from winsock_init.ipp. I've tried linking a few libraries (this time I have the
.a files, one of the libs I tried linking was system) but I haven't resolved the issue.
Quote from: Alpha on August 25, 2011, 03:05:56 am
I think the overall problem is that the library ws2_32 needs to be added to the linker.
As you seem to have found, asio (on Windows) requires the Windows
Sockets API; support for it can be added by linking to the library ws2_32 (it
is included in minGW, so you do not need to find it).
Quote from: aaronds on August 25, 2011, 05:44:59 pm
2/26/2015 7:52 PM
6 of 12
http://forums.codeblocks.org/index.php?topic=15164.0
That is because asio does not have a library, it just requires the
Boost.System library (and the Winsock library).
Quote from: aaronds on August 25, 2011, 05:44:59 pm
I don't seem to have a build options tab :S
See if this screenshot helps. (The arrows scroll the tabs left and right, so
the Build options tab may not be visible at first.)
Last Edit: September 01, 2011, 11:10:37 pm by Alpha
aaronds
Newcomer
Logged
Posts: 5
Hi Alpha, sorry I was away for a few days. Thanks very much for your help, I
got boost configured and working fine!
Thanks again
Logged
Alpha
Developer
Lives here!
Posts: 1442
ptolomey
Advanced newcomer
Posts: 12
b) C:\Program Files\CodeBlocks\Boost\include\boost-1_47\boost
\lambda\detail\operator_lambda_func_base.hpp:60|56|instantiated from
'boost::lambda::detail::binary_rt<boost::lambda::bitwise_action<boost::lambda::leftshift_a
boost::tuples::tuple<std::basic_ostream<char>&,
boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::arith
boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::placeholder<1>
>, const int, boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type, boost::tuples::null_type, boost::tuples::nu|
c) C:\Program Files\CodeBlocks\Boost\include\boost-1_47\boost
\lambda\detail\lambda_functors.hpp:202|50|instantiated from 'typename
2/26/2015 7:52 PM
7 of 12
http://forums.codeblocks.org/index.php?topic=15164.0
d) c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.5.2
\include\c++\bits\stl_algo.h:4185|2|instantiated from '_Funct
std::for_each(_IIter, _IIter, _Funct) [with _IIter =
std::istream_iterator<int>, _Funct =
boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::bitw
boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::lambda_functor_base
boost::tuples::tuple<std::basic_ostream<char>&,
boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boo|
2) Used software versions
a. Code::Blocks 10.05
b. MinGW 4.6
c. Boost 1.47.0
3) Boost libraries were built after several manipulations described below
a. In file \boost_1_47_0\bootstrap.bat line set toolset=msvc was
replaced with line set toolset=gcc
b. In file \boost_1_47_0\tools\build\v2\engine\build.bat under
the procedure :Guess_toolset updates the MinGW entry to point to the
correct folder:
Code: [Select]
call :Clear_Error
if EXIST "C:\Program Files\CodeBlocks\MinGW\bin\gcc.exe" (
set "BOOST_JAM_TOOLSET=mingw"
set "BOOST_JAM_TOOLSET_ROOT=C:\Program Files\CodeBlocks\MinGW\"
goto :eof)
c. In file \boost_1_47_0\tools\build\v2\engine\build.bat,
removed all other blocks of code similar to the above codeblock from the
procedure :Guess_toolset
d. Compiled and Built the Boost C++ Library binaries
i. In CMD (command line) enter the command: c:\boost_1_47_0
\bootstrap.bat, it successfully built the executable Bjam.exe
ii. To build the Boost Library binaries entered command in CMD:
Code: [Select]
bjam --toolset=gcc --build-type=complete "--prefix=C:\Program Files\CodeBlocks\Boost" install
2/26/2015 7:52 PM
8 of 12
http://forums.codeblocks.org/index.php?topic=15164.0
Files\CodeBlocks\Boost\include\boost-1_47
iv. In field lib entered following path: C:\Program Files\CodeBlocks
\Boost\lib
5. Setting Code::Blocks Project Build Options
a. In Project->Build options...
i. Ensured that the overall name of the project is selected in the
left-hand column
ii. In Search directories tab Compiler sub-tab filed entered
$(#boost)
iii. In Search directories tab Linker sub-tab filed entered
$(#boost.lib)
Logged
Alpha
Developer
Lives here!
Posts: 1442
d) c:\program files\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.5.2\include\c++\bits
\stl_algo.h:4185|2|instantiated from '_Funct std::for_each(_IIter, _IIter, _Funct) [with _IIter
= std::istream_iterator<int>, _Funct =
boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::bitwise_action<boost::lam
boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::bitwis
boost::tuples::tuple<std::basic_ostream<char>&,
boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boo|
Quote from: ptolomey on October 18, 2011, 07:04:43 pm
2) Used software versions
a. Code::Blocks 10.05
b. MinGW 4.6
c. Boost 1.47.0
ptolomey
Advanced newcomer
Posts: 12
2/26/2015 7:52 PM
9 of 12
http://forums.codeblocks.org/index.php?topic=15164.0
ptolomey
Advanced newcomer
Posts: 12
Finally I succeeded.
The only mistake was in definition of CodeBlocks Search Directories of
Compiler.
It has to be: $(#boost.include) and NOT $(#boost) as written in Wiki
http://wiki.codeblocks.org/index.php?title=BoostWindowsQuickRef
Logged
Master
Advanced newcomer
hello all , i have the same problem getting boost to work with CB .
i can compile this source code :
Code: [Select]
#include <boost/lambda/lambda.hpp>
#include <iostream>
Posts: 53
#include <iterator>
#include <algorithm>
int main()
{
using namespace boost::lambda;
typedef std::istream_iterator<int> in;
std::for_each(
in(std::cin), in(), std::cout << (_1 * 3) << " " );
}
------------------the above didnt do any good so i wrote this and actually compiled just fine :
Code: [Select]
F:\ Boost_1_44_0>bjam variant=debug,release link=static address-model=32
and then
Code: [Select]
2/26/2015 7:52 PM
10 of 12
http://forums.codeblocks.org/index.php?topic=15164.0
boost::mutex mutex;
void thread()
{
for (int i = 0; i < 5; ++i)
{
wait(1);
mutex.lock();
std::cout << "Thread " << boost::this_thread::get_id() << ": " << i << std::endl;
mutex.unlock();
}
}
int main()
{
boost::thread t1(thread);
then i added to the Linker section and selected all of the files in stage/libs :
these are :
here is the pic :
2/26/2015 7:52 PM
11 of 12
http://forums.codeblocks.org/index.php?topic=15164.0
2/26/2015 7:52 PM
12 of 12
http://forums.codeblocks.org/index.php?topic=15164.0
Go Up
previous next
Code::Blocks User forums Help Configuring Boost with Code::Blocks
go
2/26/2015 7:52 PM