Author Topic: Boost issues  (Read 4923 times)

Offline H

  • Multiple posting newcomer
  • *
  • Posts: 15
Boost issues
« on: September 04, 2009, 03:23:45 am »
Okay just to clarify, I have read the BoostWindowsQuickReference. Now here's the story.

When I first tried to get boost, all I did was download the latest zip file and extract it into the CodeBlocks folder. Then I set the compiler settings to look in the boost folder. This allowed me to compile, but not to link. I then read the BoostWindowsQuickReference. I removed everything I had related to boost from my machine, and started fresh. I followed the instructions step by step, and the only thing that didn't go exactly as the instructions said was that the install-proper folder with the include\boost inside of it was in C: and not my CodeBlocks folder. So I simply copied it (just in case for some reason it needed to be there) to the CodeBlocks folder, which I thought odd because I already had a boost_1_40_0 folder there from downloading the .zip.

I then tried to compile a program and it came up with the exact same error. Then I realized that I forgot to put in the link library (Ex: boost_regex-mgw44-mt-1_40.lib). Now I get the error:
ld.exe||cannot find -lboost_regex-mgw44-mt-1_40.lib|

I have a few questions:
1. What am I doing wrong?
2. Will I need to put in a link library every time I want to use a boost facility (everything is separated into different files, there isn't just one big project.)
3. Was it necessary to build the library with the boost-jam or could I have just extracted it and used it?
4. Should I try nuwen's MinGW Distro? (Would it make things any easier?)
« Last Edit: September 04, 2009, 03:29:32 am by H »

Offline Seronis

  • Almost regular
  • **
  • Posts: 197
Re: Boost issues
« Reply #1 on: September 04, 2009, 07:24:16 am »
A lot of the boost classes can be used header only though several major ones (threads, regex, datetime) do need compiled first.  That aside the boost libraries that are compiled on windows are not named in a manner that gcc expects so you need to make sure you use the full pathname of the libs in the linker options.  I really loathe having pathnames in my project files so i rely on the global variables feature so that i can do something like

$(#boost.lib)\libboost_regex-mgw44-mt.lib

That allows the *.lib to be fully resolved but still allows me to use the same project file on multiple machines without causing problems.  Hope this helps.

Offline TDragon

  • Lives here!
  • ****
  • Posts: 936
    • Twilight Dragon Media
Re: Boost issues
« Reply #2 on: September 04, 2009, 05:05:19 pm »
Actually, as long as you understand how the naming scheme works, it is possible to have the linker find .lib files without specifying the full path. There was a typo in the BoostWindowsQuickRef which I just now fixed, but basically as long as you specify the file *without* the .lib extension (and specify the right linker search path as always), the linker will find it.

So, H, just get rid of the ".lib" extensions from your link libraries, and it'll work.

For those interested in how the GCC linker finds "-l" libraries -- if you specify "-lasdf", it searches for a file named "libasdf.a" *OR* "asdf.lib". The file extension should always be omitted, unless you're also specifying the full path to the file.
http://tdm-gcc.tdragon.net/ - TDM-GCC compiler suite for Windows (GCC 5.1.0 2015-06-28, 32/64-bit, no extra DLLs)

Offline TDragon

  • Lives here!
  • ****
  • Posts: 936
    • Twilight Dragon Media
Re: Boost issues
« Reply #3 on: September 04, 2009, 05:24:04 pm »
Hm; actually, Code::Blocks tries to be too smart in this instance. I had to tack an extra "lib" on the front of the library name because C::B was removing it. I think the library name parser logic needs upgrading.
http://tdm-gcc.tdragon.net/ - TDM-GCC compiler suite for Windows (GCC 5.1.0 2015-06-28, 32/64-bit, no extra DLLs)

Offline H

  • Multiple posting newcomer
  • *
  • Posts: 15
Re: Boost issues
« Reply #4 on: September 04, 2009, 06:58:45 pm »
Well I actually tried using the MinGW distro on Nuwen's site. I downloaded the Code::Blocks binary release without MinGW, and then downloaded the MinGW from the other site (I used that because his distribution includes boost and a lot of other useful libraries.) Now I need to figure out how to get Code::Blocks to recognize it.

The MinGW is located in C:\
and Code::Blocks is located in C:\Program Files (x86)

I've fiddled around with the compiler settings by using http://wiki.codeblocks.org/index.php?title=Installing_MinGW_with_Vista but still can't get it. When I try to compile something, nothing happens.

Edit: I got it working. I had to change the Paths because the defaults were wrong. Now to test boost.
« Last Edit: September 04, 2009, 07:10:30 pm by H »

Offline Seronis

  • Almost regular
  • **
  • Posts: 197
Re: Boost issues
« Reply #5 on: September 04, 2009, 07:50:46 pm »
Hm; actually, Code::Blocks tries to be too smart in this instance. I had to tack an extra "lib" on the front of the library name because C::B was removing it. I think the library name parser logic needs upgrading.

Yeah.  I actually had this -exact- problem awhile ago.

http://forums.codeblocks.org/index.php/topic,10257.0.html

Jens ended up pointing me to a reference showing that gcc doesnt support use of library names formated as lib<name>.lib.     <name>.lib and  lib<name>.a it supports.  But the boost naming scheme is taboo it seems.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9488
Re: Boost issues
« Reply #6 on: September 04, 2009, 08:56:36 pm »
But the boost naming scheme is taboo it seems.
It's not taboo but just not a standard. However - if you provide a direct link to the library (using a full/relative path or using a GCV as suggested) this will always work.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline TDragon

  • Lives here!
  • ****
  • Posts: 936
    • Twilight Dragon Media
Re: Boost issues
« Reply #7 on: September 04, 2009, 09:09:50 pm »
The FAQ Jens quoted may be somewhat misleading. The rules GNU LD follows when looking for libraries by name on Windows are quite simple, and to call the use of "lib<name>.lib" unsupported or taboo is plain silly. C::B's link libraries facility needs to be changed so that the only time it removes a "lib" prefix is when it has also removed a ".a" suffix.
http://tdm-gcc.tdragon.net/ - TDM-GCC compiler suite for Windows (GCC 5.1.0 2015-06-28, 32/64-bit, no extra DLLs)

Offline H

  • Multiple posting newcomer
  • *
  • Posts: 15
Re: Boost issues
« Reply #8 on: September 04, 2009, 10:13:47 pm »
Well I built it, even though at the end of the build there were a lot of errors regarding linking. I"ll try what you said now.
« Last Edit: September 04, 2009, 11:50:32 pm by H »

Offline H

  • Multiple posting newcomer
  • *
  • Posts: 15
Re: Boost issues
« Reply #9 on: September 05, 2009, 12:08:39 am »
I think I figured it out. I needed to set a path to the MinGW compiler executables.

Edit: I finally got it to work. Basically I was stuck figuring out what to do for the search directory, but instead I just went to linker settings and copied/added all of the libraries in there. Now it works.
« Last Edit: September 05, 2009, 06:10:12 am by H »

Offline nanyu

  • Almost regular
  • **
  • Posts: 187
  • nanyu
Re: Boost issues
« Reply #10 on: October 08, 2009, 05:51:56 pm »
Hm; actually, Code::Blocks tries to be too smart in this instance. I had to tack an extra "lib" on the front of the library name because C::B was removing it. I think the library name parser logic needs upgrading.

Hi! I have to write the extra "lib" , (etc : liblibboost_thread-mgw34-mt-d) to the "link libraries" list box still.

Does this BUG come from gcc?  or from Code::Blocks? If it's a bug of Code::Blocks,would it been fix future?

-----------------
windows xp
mingw32
gcc 3.4.5
« Last Edit: October 08, 2009, 05:55:29 pm by nanyu »