User forums > Help

Configuring Boost with Code::Blocks

<< < (2/6) > >>

Alpha:

--- Quote from: aaronds on August 25, 2011, 01:03:40 am ---The code example appears to compile, but it doesn't output anything to the CMD window (it just seems to hang...?).

--- End quote ---
Oh, I should have mentioned all it does is multiply the input number by 3 (you need to type a number and press enter).


--- Quote from: aaronds on August 25, 2011, 01:03:40 am ---
--- 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.

--- End quote ---
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/.

--- End quote ---
Sorry, I apparently was not thinking when I replied previously; /stage/lib/ is the default folder (not lib).

I think the overall problem is that the library ws2_32 needs to be added to the linker.  Your build configuration does sound slightly different than mine, so if adding this library (as well as keeping the other necessary libraries) does not fix the problem, use the following steps to rebuild boost from scratch.

Download either the zip or the 7zip package from this page.  Extract the contents to extract_dir.

Open Command Prompt (cmd.exe) and navigate to extract_dir.
cd extract_dir

If the minGW\bin folder is not in the path variable add it.
path minGW_dir\bin;%path%

Build the boost build system by entering
bootstrap mingw

Open the file extract_dir\project-config.jam in Notepad and change the word msvc to gcc.

Back in the Command Prompt window, run
b2

If it still does not work, post a build log.

--- Quote from: Alpha on August 25, 2011, 12:20:10 am ---go to Settings->Compiler and debugger...->Build options (tab) and check Save build log and Always output the full command line.

--- End quote ---

aaronds:
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 ---The code example appears to compile, but it doesn't output anything to the CMD window (it just seems to hang...?).

--- End quote ---
Oh, I should have mentioned all it does is multiply the input number by 3 (you need to type a number and press enter).

--- End quote ---
My bad, I only scan-read the code quickly before running it.

Edit:

Seem much closer than before. One last error to get rid of when attempting to use asio.

--- Code: ---undefined reference to `WSACleanup@8
undefined reference to `WSACleanup@0
--- End code ---
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.)

--- End quote ---
I don't have any .a file that has asio in the name.


--- Quote from: aaronds on August 25, 2011, 01:03:40 am ---If it still does not work, post a build log.

--- Quote from: Alpha on August 25, 2011, 12:20:10 am ---go to Settings->Compiler and debugger...->Build options (tab) and check Save build log and Always output the full command line.

--- End quote ---

--- End quote ---
I don't seem to have a build options tab :S

Thanks again for your help.

Alpha:

--- Quote from: aaronds on August 25, 2011, 05:44:59 pm ---One last error to get rid of when attempting to use asio.

--- Code: ---undefined reference to `WSACleanup@8
undefined reference to `WSACleanup@0
--- End code ---
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.

--- End quote ---

--- 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.

--- End quote ---
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 ---I don't have any .a file that has asio in the name.

--- End quote ---
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

--- End quote ---
See if this screenshot helps.  (The arrows scroll the tabs left and right, so the Build options tab may not be visible at first.)

aaronds:
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

Alpha:
Glad to be of assistance (and that it worked).  If you feel comfortable enough with it, you might consider updating the boost page on the Code::Blocks wiki.  (If not, I probably will when I get around to it.)

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version