hello, I'm trying to install and use boost graph library file sin my code blocks IDE for C++ program but am unable to.Please help.

Dani AI

Generated

A short, practical checklist that ties together the points from and the OP: the usual causes for "no such file or directory" are a wrong include path, a typo in the include line, Code::Blocks using a different compiler/toolchain than expected, or confusing runtime DLLs with what the compiler needs at build time. The following steps focus on verifying the include path and the compiler toolchain before worrying about any binary libraries.

  • Locate the Boost headers on disk (search for a small header such as boost/version.hpp or boost/config.hpp) and note the parent folder that contains the boost directory.
  • In Code::Blocks add that parent folder to the compiler search path (Project → Build options → Search directories → Compiler, or put it in the Global compiler settings if you want it available for all projects). Make sure the path points to the directory that directly contains the boost folder, not to a nested header file.
  • Confirm the actual compiler used by Code::Blocks (Settings → Compiler → Toolchain executables). If libraries were built with a different toolchain, the compiler and import libraries must match.
  • Quick command-line sanity check: create a tiny file that includes boost/version.hpp and compile it with an explicit -I to the folder found above. Example:
/* test_boost.cpp */
#include <boost/version.hpp>
#include <iostream>
int main() { std::cout << BOOST_LIB_VERSION << "\n"; }

g++ -IC:\path\to\boost_root test_boost.cpp -o test_boost
  • If a particular Boost component requires a prebuilt binary, link the correct import libraries for your compiler (not raw DLL files) and add their folder under Linker search paths.

Note: 's mention of g2++.h is a separate dependency; that header is not part of Boost and must be resolved independently. Checking the verbose build log in Code::Blocks will show the exact compiler command line and the -I paths actually used, which often reveals the mistake.

Recommended Answers

All 7 Replies

All you need to do, since BGL is a header-only library, is to add the include directory for boost in your CB project.

First, of course, you need to have installed Boost libraries, by following the instructions on the www.boost.org Getting Started page.

After that, you should have boost installed to some directory that you specified.

Then, in CB, you go to project/build-options and add, under include directories, the boost/include directory from where your boost installation was done. Then, all should be fine.

All you need to do, since BGL is a header-only library, is to add the include directory for boost in your CB project.

First, of course, you need to have installed Boost libraries, by following the instructions on the www.boost.org Getting Started page.

After that, you should have boost installed to some directory that you specified.

Then, in CB, you go to project/build-options and add, under include directories, the boost/include directory from where your boost installation was done. Then, all should be fine.

how do I add library?The boost folder doesnt have any .lib or .dll file..

BGL is header-only, it does not require a library (at least, I think so).

If you do need to link to boost libraries, you need to follow the instructions on the boost website to build the libraries using MinGW GCC. That must be done in command-line (command prompt), using Boost's build system (BJam).

Normally, the libraries get installed into "boost_install_folder/lib/stage/". And, depending on the options you use for the build, they will have either .a or .lib extensions.

If you need to use the libraries for another compiler (like the microsoft compiler), you will need to build them with that compiler as well.

I installed using Boostpro installer.I did add the library files in the linker settings yet while debugging , i get the error "no such file or directory" for g2++.h and every other file.

g2++.h is not part of Boost, it is part of the g2 library. That problem is not related to Boost, since Boost does not contain external dependencies (especially not from such dubious source) except for the standard libraries. Additionally, I find it bizarre to have a file name that includes ++ in its name, some operating systems might not even be able to find it just because of the odd characters in the filename.

Just try to compile a simple BGL example from the tutorials and see if that works. That should tell you if your Boost installation is correct.

If you are using, alongside, other external libraries, and that some of those use this g2 library, deeming it OK to do so, it means you will most probably have further problems with that external dependency (Boost installation will be the last of your worries).

okay let me put it this way.
I linked .dll files from lib folder of boost in the linker add section of CB
Then i tried to compile a simple BGL code with header file "boot/adjacency_list.h"
It gives the error no such directory found.
Please give a step by step procedure as to how to go about it.I'm stuck!!

You need to also specify the "include directory" of boost, not just the link directory. The headers (such as adjacency_list.h) are in the boost include directory, not where the libs are. BTW, I'm pretty sure you need to include "boost/graph/adjacency_list.h"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.