Author Topic: Using Boost in Code Blocks  (Read 8879 times)

Offline maxim6394

  • Single posting newcomer
  • *
  • Posts: 3
Using Boost in Code Blocks
« on: August 11, 2015, 09:55:01 pm »
I'm trying for quite a while now to use the boost libraries in code blocks, but I always get the error "no such file or directory" when I try to include a .hpp file from the boost directory. I'm using MinGW with boost included. I created a new variable in code blocks named "boost", with the base path pointing to the include/boost/ directory of the minGW installation. The wiki page says I have to add "stage\lib" in the lib field but that subdirectory doesn't exist.
Any indeas?


Offline maxim6394

  • Single posting newcomer
  • *
  • Posts: 3
Re: Using Boost in Code Blocks
« Reply #2 on: August 12, 2015, 11:31:53 am »
I am running Code::Blocks version 13.12 on Windows 7. The compiler I use is MinGW GCC version 5.1.0.

When I try to use the Boost library in my project, the files aren't found. I tried to follow the steps on the wiki page, I also tried to build the boost library but I only get this error:
Code
O:\developement\CPP\boost_1_46_1\boost_1_46_1>bootstrap.bat --toolset=gcc "--pre
fix=C:\asdf\" install
Building Boost.Jam build engine
Der Befehl "cl" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.

Failed to build Boost.Jam build engine.
Please consult bjam.log for furter diagnostics.

You can try to obtain a prebuilt binary from

   http://sf.net/project/showfiles.php?group_id=7586&package_id=72941

Also, you can file an issue at http://svn.boost.org
Please attach bjam.log in that case.

I thought it wasn't necessary to build the library because it's already included with the compiler, but I still don't really know how to use it.

Build log:
Code

-------------- Build: Debug in Project3 (compiler: GNU GCC Compiler)---------------

g++.exe -Wall -fexceptions -g -std=c++11 -IC:\Qt\5.5\msvc2013_64\include -IO:\developement\CPP\boost-1.30.1\boost-1.30.1\include -IC:\MinGW\MinGW\include\boost -IC:\Users\maxim\Documents\Development\CPP\cpp_project\Project3 -c C:\Users\maxim\Documents\Development\CPP\cpp_project\Project3\main.cpp -o obj\Debug\main.o
C:\Users\maxim\Documents\Development\CPP\cpp_project\Project3\main.cpp:4:25: fatal error: boost/asio.hpp: No such file or directory
compilation terminated.
Process terminated with status 1 (0 minute(s), 7 second(s))
1 error(s), 0 warning(s) (0 minute(s), 7 second(s))

Offline scarphin

  • Lives here!
  • ****
  • Posts: 640
Re: Using Boost in Code Blocks
« Reply #3 on: August 12, 2015, 11:56:28 am »
So you are using MinGW as your compiler and Visual Studio compiled binaries for Qt:
Code
-IC:\Qt\5.5\msvc2013_64\include
Do you have a reasoning for that?

From what I see from your build log:
Code
-IO:\developement\CPP\boost-1.30.1\boost-1.30.1\include
-IC:\MinGW\MinGW\include\boost
you should have the file:
Code
O:\developement\CPP\boost-1.30.1\boost-1.30.1\include\boost\asio.hpp
or
Code
C:\MinGW\MinGW\include\boost\boost\asio.hpp
Do you have either one of these files? If not, then you're not including the correct paths.

If your compiler includes boost why are you using a separate boost installation?

Also please don't ask boost (or any other library) related questions here. None of those are supported nor allowed unless it's a CodeBlocks related problem.

Btw current boost version is 1.58 or something, why do you use such old boost versions (1.30, 1.46)?

Offline maxim6394

  • Single posting newcomer
  • *
  • Posts: 3
Re: Using Boost in Code Blocks
« Reply #4 on: August 12, 2015, 01:18:16 pm »
I think I finally got it. I tried the included libray and also tried to build the seperate installation and neither worked.
Adding "C:\MinGW\MinGW\include" to the search path for the project apparently was the solution, I think I only tried including "C:\MinGW\MinGW\include\boost", which didn't work.

The subdirectory \boost-1.30.1\include\ doesn't even exist and also the boost.org website is unreachable for me, I only get a connection timeout so I got the files somewhere else.

Offline cacb

  • Lives here!
  • ****
  • Posts: 547
Re: Using Boost in Code Blocks
« Reply #5 on: August 13, 2015, 04:38:35 pm »
I am not using MinGW, but I am using boost (old version, but ignore that)

I have created a Code::Blocks global variable "boost"
Code
base:     [path]\boost\boost_1_49_0
include:  [path]\boost\boost_1_49_0
lib:      [path]\boost\boost_1_49_0\stage\lib

(replace [path] with the path to where your boost is installed. Obviously set the version number to the relevant number you are using)

Then in your project build options "Search directories", add
compiler: $(#boost.include)
linker: $(#boost.lib)

Sometimes you also have to add the library name in the "linker settings",