Hi Stephen !


On Monday 29 December 2008, Stephen wrote:
> Trying to port a mac program onto windows. I've been having some
> trouble getting the boost portion of it to work. It appears to run
> fine in release mode*, but crashes when debugged. Below is an
> excised piece of code that seems to replicate the problem, and works
> perfectly in release mode but crashes when debugging.


This seems to be a build issue on your side.


> I'm using Code::Blocks under XP, with Boost 1.37 with Mingw 3.4.5
> (linking to boost_system-mgw34-mt-1_37.lib and
> boost_filesystem-mgw34-mt-1_37.lib )


Also in debug mode ?


I've tried to reproduce your problem with
Boost Trunk
and inofficial (or experimental) mingw-4.3.2-tdm2 from
http://www.tdragon.net/recentgcc/


and it does work. Please find a sample project using bjam and Boost.Test attached. It would be great if you could test this with your setup.
I've looked at the regression test but no-one seems to be running mingw-3.4.x tests continuously (some stalled on trunk, none on release)


> (Also: It doesn't crash when I run it in windows 95 compatibility
> mode, but that's not really an option because that completely breaks
> the program it's meant to be a part of).


This is another sign for build misconfiguration.



> Doing a similar build in Visual C++ 2008 with msvc builds of the
> library, I get the error
>
> Unhandled exception at 0x7c812aeb in filesystest.exe: Microsoft C++
> exception:
> boost::exception_detail::clone_impl<boost::exception_detail::error_in
>fo_injector<boost::filesystem::basic_filesystem_error<boost::filesyste
>m::basic_path<std::basic_string<char,std::char_traits<char>,std::alloc
>ator<char>
>
> >,boost::filesystem::path_traits> > at memory location 0x0012fb34..
>
> whether I run a debug build or not.


That's is the constructor throwing an exception when setting up with an invalid path. Try to catch it.


Using
fs::path p("bla");
your example throws:


unknown location(0): fatal error in "filesystem": std::runtime_error: boost::filesystem::basic_directory_iterator constructor: The system cannot find the path specified: "bla"
unknown location(0): fatal error in "filesystem": std::runtime_error: boost::filesystem::basic_directory_iterator constructor: The system cannot find the path specified: "bla"


at least with mingw-4.3.2


> Compiling with the debug builds of the libraries
> (X-mgw34-mt-d-1_37.lib) didn't produce significantly-different
> looking other errors from the ones above.


interesting.


> Someone on the internet (
> http://forums.codeblocks.org/index.php/topic,8429.msg64317.html#msg64
>317 ) seemed to have a similar problem, but his solution isn't
> satisfactory for me (for the reason given below). Linking to
> single-threaded builds of boost didn't seem to make a difference
> either.
>
> Any help with this would be really appreciated.


My last guess would be static vs. dynamic runtime libraries...


Yours,


Jürgen
--
* Dipl.-Math. Jürgen Hunold ! Ingenieurgesellschaft für
* voice: ++49 511 262926 57 ! Verkehrs- und Eisenbahnwesen mbH
* fax : ++49 511 262926 99 ! Lister Straße 15
* juergen.hunold@ivembh.de ! www.ivembh.de
*
* Geschäftsführer: ! Sitz des Unternehmens: Hannover
* Prof. Dr.-Ing. Thomas Siefer ! Amtsgericht Hannover, HRB 56965
* PD Dr.-Ing. Alfons Radtke !