Author Topic: using boost/filesystem  (Read 22436 times)

Offline kanesoban

  • Multiple posting newcomer
  • *
  • Posts: 10
using boost/filesystem
« on: July 08, 2008, 10:26:56 pm »
Helo,

my problem is the following: there are some things i want to use in the boost/filesystem library.
http://www.boost.org/doc/libs/1_35_0/libs/filesystem/doc/index.htm

However, i have no idea, how to install 3rd party libraries. I've read through boost's website, but it mostly contains instructions on installing boost with Ms Visual Studio. With other IDEs, the site says, that
"if you're using an earlier version of Visual Studio or some other compiler, or if you prefer to build everything yourself, you can download boost_1_35_0.exe and run it to install a complete Boost distribution"

There is a link to the sourceforge boost page, but there is no exe to download.


Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9508
Re: using boost/filesystem
« Reply #1 on: July 08, 2008, 10:47:03 pm »
There is a link to the sourceforge boost page, but there is no exe to download.
Probably you are just a bit too early? I didn't even realise that boost 1.35.0 is out... :shock:
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 killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5193
Re: using boost/filesystem
« Reply #2 on: July 08, 2008, 11:35:24 pm »
note not everything from boost needs to be build Several things are just simple templates in header files, no idea about the filesystem, never used that part

By the way : in linux you get a free ride, most distros have it as a package : binary and headers :-)

Longe live linux :-) :-)

Offline TDragon

  • Lives here!
  • ****
  • Posts: 936
    • Twilight Dragon Media
Re: using boost/filesystem
« Reply #3 on: July 09, 2008, 03:31:56 am »
The documentation is in error; an .exe is no longer distributed. You can download whichever of the archives on the SourceForge download page is easiest for you to extract.

boost::filesystem does indeed need to be built. Follow the directions here. You haven't specified which compiler you're using, so I'll assume it's the installation of MinGW included with the full Code::Blocks 8.02 download. Your toolset, for the purposes of building Boost, is "gcc". You will need to ensure the "bin" subdirectory (containing gcc.exe and friends) is in the PATH environment variable before invoking bjam.

Cheers,
John E.
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 kanesoban

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: using boost/filesystem
« Reply #4 on: July 09, 2008, 04:03:46 pm »
"You haven't specified which compiler you're using"

It's gcc 3.4.4.

"You will need to ensure the "bin" subdirectory (containing gcc.exe and friends) is in the PATH environment variable before invoking bjam."

How do i do that ?

Offline TDragon

  • Lives here!
  • ****
  • Posts: 936
    • Twilight Dragon Media
Re: using boost/filesystem
« Reply #5 on: July 09, 2008, 06:15:27 pm »
You can do it permanently by adding it in the Environment Variables applet (Control Panel / System / Advanced / Environment Variables). A "Path" entry is usually already present, and you can just tack ";C:\MinGW\bin" on to the end of it (assuming MinGW is installed in C:\MinGW).

Or you can do it for the length of a single command prompt session with:
Code: [Select]
set PATH=%PATH%;C:\MinGW\bin

You will also need to do this for the path to bjam.exe, unless you put it in the root of the Boost sources.

A final note:
Questions like this are not truly appropriate for the Code::Blocks forums. If you have further difficulties, you should use the MinGW or Boost mailing lists.
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 kanesoban

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: using boost/filesystem
« Reply #6 on: July 11, 2008, 09:50:01 pm »
Helo again,

i think i succesfully built boost. Now, the next question is, how do i link it in Codeblocks to my program ?

Note:
boost build directory is C:\Documents and settings\Kane\build-boost\

Offline TDragon

  • Lives here!
  • ****
  • Posts: 936
    • Twilight Dragon Media
Re: using boost/filesystem
« Reply #7 on: July 12, 2008, 12:09:11 am »
Now, the next question is, how do i link it in Codeblocks to my program ?

* Add whatever folder contains the boost/*.hpp files to your project's include search directories.
* Add whatever folder contains the library files you just built to your project's library search directories.

Then you can add the name of the library you want to link in your project's libraries to link.
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 kanesoban

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: using boost/filesystem
« Reply #8 on: July 14, 2008, 06:16:20 pm »
Quote
* Add whatever folder contains the boost/*.hpp files to your project's include search directories.
* Add whatever folder contains the library files you just built to your project's library search directories.

Please write this down in simpler steps, and more detail.

Offline TDragon

  • Lives here!
  • ****
  • Posts: 936
    • Twilight Dragon Media
Re: using boost/filesystem
« Reply #9 on: July 14, 2008, 08:18:35 pm »
Depending on how you've run bjam, the full path to filesystem.hpp will be like "DriveLetter:\Path\To\SomethingWithBoostInIt\include\boost_1_35\boost\filesystem.hpp". In this case, add "DriveLetter:\Path\To\SomethingWithBoostInIt\include\boost_1_35" in the list of directories in the Compiler tab of the Search Directories tab of your project's Build options.

Also depending on how you've run bjam, the full path to libboost_filesystem-1_35.a will be like "DriveLetter:\Path\To\SomethingWithBoostInIt\MaybeLib\libboost_filesystem-1_35.a". In this case, add "DriveLetter:\Path\To\SomethingWithBoostInIt\MaybeLib" in the list of directories in the Linker tab of the Search Directories tab of your project's Build options.

Then, add "boost_filesystem-1_35" to the list of libraries to link in the Linker tab of your project's Build options.

Obviously, you'll have to do a smidge of creative thinking in order to figure out exactly what paths to use. The name of the library file might even be wrong. This is because A) I'm not at a computer with Boost installed, and B) if you can't figure it out, then there are some basic programming concepts you need to learn first.
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 dje

  • Lives here!
  • ****
  • Posts: 683
Re: using boost/filesystem
« Reply #10 on: July 14, 2008, 09:29:14 pm »
Could you give more details on
Quote
some basic programming concepts
?  :lol: :lol: :lol:

Offline TDragon

  • Lives here!
  • ****
  • Posts: 936
    • Twilight Dragon Media
Re: using boost/filesystem
« Reply #11 on: July 15, 2008, 05:13:39 am »
Sure. In this case, there are two that apply:
1. RTFM! The boost documentation tells you about the various libraries that are built and how to use them.
2. Understand your compiler! You need to grasp of the concepts of compile-time and link-time resolution and what files and commands the compiler needs in order to perform them. See (1) as applied to the compiler documentation, take a class in C or C++, or read a book.

And that's as detailed as is appropriate for the Code::Blocks forums.

Cheers,
John E.
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 kanesoban

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: using boost/filesystem
« Reply #12 on: July 15, 2008, 11:29:19 am »
Quote
...add "DriveLetter:\Path\To\SomethingWithBoostInIt\include\boost_1_35" in the list of directories in the Compiler tab of the Search Directories tab of your project's Build options.

Done.

Quote
Also depending on how you've run bjam, the full path to libboost_filesystem-1_35.a will be like "DriveLetter:\Path\To\SomethingWithBoostInIt\MaybeLib\libboost_filesystem-1_35.a". In this case, add "DriveLetter:\Path\To\SomethingWithBoostInIt\MaybeLib" in the list of directories in the Linker tab of the Search Directories tab of your project's Build options.

Strange. There is no such file on my entire hard-drive. Maybe i didn't succeed in building boost after all ?

Quote
Then, add "boost_filesystem-1_35" to the list of libraries to link in the Linker tab of your project's Build options.

Done.

Now, the compiler gives this message when i try to build my project:

C:\Program Files\CodeBlocks\bin\..\lib\gcc\mingw32\3.4.4\..\..\..\..\mingw32\bin\ld.exe: C:\Program Files\boost\boost_1_35_0\libs: No such file: Permission denied

Offline TDragon

  • Lives here!
  • ****
  • Posts: 936
    • Twilight Dragon Media
Re: using boost/filesystem
« Reply #13 on: July 15, 2008, 05:41:18 pm »
Strange. There is no such file on my entire hard-drive. Maybe i didn't succeed in building boost after all ?
That might be so.

At any rate there should be a directory somewhere full of Boost library files that were built, several of which should have "filesystem" in the name. Like I said, I might have gotten the name of the file wrong.
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 kanesoban

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: using boost/filesystem
« Reply #14 on: July 17, 2008, 08:03:08 pm »
Quote
At any rate there should be a directory somewhere full of Boost library files that were built, several of which should have "filesystem" in the name. Like I said, I might have gotten the name of the file wrong.

Well, i'm pretty much stuck. There is no such file as you describe (no .a file that has anything to do with boost or filesystem) in my HD, and i don't know if i really succeded in building boost or not. I'm not sure, how would i know, if i did succed. I posted a message on one of the boost mailing lists asking how do i know, if the build did succed, but no answer.
What to do next?

Offline TDragon

  • Lives here!
  • ****
  • Posts: 936
    • Twilight Dragon Media
Re: using boost/filesystem
« Reply #15 on: July 18, 2008, 02:24:03 am »
What to do next?
Although providing support for 3rd party libraries is (as previously stated) outside the purview of the C::B forums, I think a quick-start guide for Boost+C::B would not go amiss in the Wiki. In the meantime, I'll also send you a personal message as soon I've rebuilt Boost myself.
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 joubertdj

  • Multiple posting newcomer
  • *
  • Posts: 120
Re: using boost/filesystem
« Reply #16 on: July 18, 2008, 08:19:47 am »
Helo again,

i think i succesfully built boost. Now, the next question is, how do i link it in Codeblocks to my program ?

Note:
boost build directory is C:\Documents and settings\Kane\build-boost\

I notice you use space within your directories ... when you use space remember to reference that with the 8.3 convention then it will "find" the files, else it will not find them ... I personally use D:\Sources\Boost, and D:\MingW, and D:\CodeBlocks ...

Best Regards,

Offline TDragon

  • Lives here!
  • ****
  • Posts: 936
    • Twilight Dragon Media
Re: using boost/filesystem
« Reply #17 on: July 18, 2008, 06:56:13 pm »
For those interested, a BoostWindowsQuickRef article is now available in the Wiki.
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 MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9508
Re: using boost/filesystem
« Reply #18 on: July 18, 2008, 10:15:25 pm »
For those interested, a BoostWindowsQuickRef article is now available in the Wiki.
Well done TDragon, nice 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 kanesoban

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: using boost/filesystem
« Reply #19 on: July 19, 2008, 04:28:44 pm »
Ok, i relocated everything, so that there are no spaces in paths (i reinstalled Codeblocks too), and i followed the Wiki exactly as it is written. No luck, though. I was trying to compile the example program here (it requires the regex library):

http://www.boost.org/doc/libs/1_35_0/more/getting_started/windows.html#link-your-program-to-a-boost-library

Message:

C:\C++\Proba_boost\main.cpp|1|boost/regex.hpp: No such file or directory|

Now, that i am looking at the bjam output, while it is a big mess, i can see a lot of g++ related "failed" messages.
By the way, g++ is in my PATH, wich looks like this:

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\CodeBlocks\MinGW\bin;C:\boost_1_35_0;

I also tried removing the semicolon from the end of PATH, and then executing bjam, but that didn't help either.

Offline TDragon

  • Lives here!
  • ****
  • Posts: 936
    • Twilight Dragon Media
Re: using boost/filesystem
« Reply #20 on: July 19, 2008, 05:07:12 pm »
Okay, the article is not quite right. I forgot about the "boost-1_35" subfolder in the includes directory. Will now correct it.

You can either (A) add the "boost" global variable and project search folders as per the skipped steps in the Wiki article, using "C:\CodeBlocks\include\boost-1_35" for the include field ("C:\CodeBlocks" for the base field), or (B) add "C:\CodeBlocks\include\boost-1_35" directly to your project's Compiler search directories.

Really, though, you should have been able to figure that out on your own. It's as simple as seeing that you want to include boost/regex.hpp, and seeing that the path boost/regex.hpp is in C:\CodeBlocks\include\boost-1_35.

Now, that i am looking at the bjam output, while it is a big mess, i can see a lot of g++ related "failed" messages.
This may or may not be normal. Hopefully the libraries you want are getting built.
« Last Edit: July 19, 2008, 05:23:33 pm by TDragon »
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 kanesoban

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: using boost/filesystem
« Reply #21 on: July 20, 2008, 01:49:21 pm »
Well, i first did A, and got this while compiling the project:

C:\CodeBlocks\MinGW\bin\ld.exe: cannot find -lboost_regex-mgw34-mt-1_35.lib

With option B it was the same error.

I tried googling what can cause this type of error, but no luck so far.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9508
Re: using boost/filesystem
« Reply #22 on: July 20, 2008, 03:54:49 pm »
C:\CodeBlocks\MinGW\bin\ld.exe: cannot find -lboost_regex-mgw34-mt-1_35.lib
this error indicates that you entered "boost_regex-mgw34-mt-1_35.lib" into the linker options which is wrong. please enter "boost_regex-mgw34-mt-1_35" (notice the missing ".lib").

In addition: You are using the MinGW compiler, right? I wonder why you get ".lib" files when you compile Boost. Using MinGW you should have compiled ".a" files...?! Probably you are mixing MinGW compilation with some unsupported format (e.g. you compiled boost wit a compiler that is not compatible with MinGW)???
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: using boost/filesystem
« Reply #23 on: July 20, 2008, 04:36:19 pm »
In addition: You are using the MinGW compiler, right? I wonder why you get ".lib" files when you compile Boost. Using MinGW you should have compiled ".a" files...?! Probably you are mixing MinGW compilation with some unsupported format (e.g. you compiled boost wit a compiler that is not compatible with MinGW)???

Nope, Boost Build causes GCC to create .lib files as of Boost 1.35.
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 MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9508
Re: using boost/filesystem
« Reply #24 on: July 20, 2008, 05:11:20 pm »
Nope, Boost Build causes GCC to create .lib files as of Boost 1.35.
I just tried: Indeed! ...how weired. :shock: That surely will cause some trouble. Strange they decided to do so.
The include folder also looks pretty strange include\boost\boost-1_35??? Huh? I just moved the files directly to boost and it seems to work as well.
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 Hitnrun

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: using boost/filesystem
« Reply #25 on: July 21, 2008, 05:17:47 pm »
Here is my boost compilling recipe (I'm using 1.34):

Code: [Select]
- using msys
- go to boost root dir
# cd tools/jam/src
# ./build.sh
- go back to boost root dir
# tools/jam/src/bin.ntx86/bjam toolset=gcc variant=release threading=multi link=static stage

Offline kanesoban

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: using boost/filesystem
« Reply #26 on: July 24, 2008, 04:14:39 pm »
Quote
this error indicates that you entered "boost_regex-mgw34-mt-1_35.lib" into the linker options which is wrong. please enter "boost_regex-mgw34-mt-1_35" (notice the missing ".lib").

It is still giving the same message.

Offline kanesoban

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: using boost/filesystem
« Reply #27 on: July 24, 2008, 05:11:00 pm »
Ok, well it seems i finally managed to compile it !

You see, the problem was, that boost build gave wrong names to some of the library files it built.
Most of the built library files look like this:
boost_*-mgw34-mt
However, for some odd reason, the regex library file (and only that) looked like this:
libboost_regex-mgw34-mt
Once i renamed it, so there is no "lib" prefix, Codeblocks was able to compile it.