The Boost C++ Libraries on a Mac

Posted on September 28, 2008. Filed under: C++, Programming | Tags: , , , |

So I’ve recently adventured into the the world of C++, attempting to write a homebrew documentation system. I soon discovered that I needed to access various features of the filesystem, a feature that is lacking in C++ without making the application heavily dependent on platform. Naturally I turned to the boost libraries, notably the filesystem library.

Typically, boost libraries are header only libraries so no source files or lib files have to be linked against, however, the filesystem library is one of those libraries that is an exception to that rule.

The instructions for building the boost libraries that require building is fairly straight forward if you know a little UNIX, however the latest release of boost has files riddled with CRLF (carriage return, line feeds) that are used in the Windows world to denote the end of a line in a file. So what you MUST do before the configure bash script will work as intended, is convert all CRLF characters to just LF characters. For building the filesystem library this includes the configure file, and the two .sh files in the tools/jam/ directory. After doing this, then follow the build instructions and be sure to use the

–prefix=my path and –with-libraries=filesystem

command line options when running configure.

Make a Comment

Make a Comment: ( 4 so far )

blockquote and a tags work here.

4 Responses to “The Boost C++ Libraries on a Mac”

RSS Feed for GDTech Comments RSS Feed

Did you download the .zip file, instead of the .tar.gz or .tar.bz2 versions? The tar versions shouldn’t have the CRLF issue you describe.

Since when do file-functions like “fopen, fread, fwrite and fclose” make you dependent on any specific platform? These functions are part of the std-c library and are available on ALL C/C++ platforms.

I find it outright frightening that somebody who’s just “recently adventured into the world of C++” recommends the Boost C++ libraries.

You need a lot more experience before recommending anything, let alone bloatware.

Michael Hartmann, two things:
- fopen et al are part of ISO C, and provide neither the C++-typical RAII idioms nor integration with std::string or iostreams.
- boost::filesystem is not about reading or writing files, but about creating, reading and modifying filesystem directories in a portable way. Oh, and it will be part of C++ TR2. So, IMHO, you don’t have the slightest clue what you’re talking about.

Perhaps I should have downloaded the .tar.gz files instead, coming from a Windows centric world I opted to download the .zip files. Noted for next time.

Thanks AK, this was exactly why I intended to use the boost libraries … portability. I wanted to write the C++ code once and be able to build on multiple environments with no difficulties.

Michael, I prefer to use the fstrem library found in the STL for creating and opening files, but I still needed a reliable and portable means for creating and traversing directory hierarchies. I could have chosen to go your route, but then I’d be shooting myself in the foot when I needed the system to run on a Windows machine. I opted for a solution that wouldn’t require any code maintenance or refactoring when porting to other environments.


Where's The Comment Form?

Liked it here?
Why not try sites on the blogroll...