0

I am trying to list items in the current directory using boost::filesystem but I get:

Unhandled exception at 0x6B59DF8D (msvcr110.dll) in BoostTest.exe: 0xC0000005: Access violation reading location 0x9BE3B7A1.

Here is my code:

#include <iostream>
#include <boost/filesystem.hpp>

using namespace boost::filesystem;

int main() {
    std::cout << "Hello World!\n";
    auto end_it = directory_iterator();
    for(auto it = directory_iterator(current_path()); it != end_it; it++) {
        std::cout << it->path() << std::endl;
    }
    std::cin.get();
    return 0;
}

I have just switched over to vs2012 from mingw and I think it could be a linking error or something like that. I'm linking with these 32 bit libraries:

  • boost_filesystem-vc110-mt-1_52.lib

And these files are in the directory of the executable:

  • boost_filesystem-vc110-mt-1_52.dll
  • boost_system-vc110-mt-1_52.dll

downloaded from this website: http://boost.teeks99.com/

and the platform is set to "Win32".

Here is the log from the Visual Studio 2012 window:

'BoostTest.exe' (Win32): Loaded 'C:\Users\Ell\Programming\C++\BoostTest\Debug\BoostTest.exe'. Symbols loaded.
'BoostTest.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Cannot find or open the PDB file.
'BoostTest.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Cannot find or open the PDB file.
'BoostTest.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Cannot find or open the PDB file.
'BoostTest.exe' (Win32): Loaded 'C:\Users\Ell\Programming\C++\BoostTest\Debug\boost_filesystem-vc110-mt-1_52.dll'. Module was built without symbols.
'BoostTest.exe' (Win32): Loaded 'C:\Users\Ell\Programming\C++\BoostTest\Debug\boost_system-vc110-mt-1_52.dll'. Module was built without symbols.
'BoostTest.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp110.dll'. Symbols loaded.
'BoostTest.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr110.dll'. Symbols loaded.
'BoostTest.exe' (Win32): Loaded 'C:\Windows\SysWOW64\advapi32.dll'. Cannot find or open the PDB file.
'BoostTest.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcrt.dll'. Cannot find or open the PDB file.
'BoostTest.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'. Cannot find or open the PDB file.
'BoostTest.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'. Cannot find or open the PDB file.
'BoostTest.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'. Cannot find or open the PDB file.
'BoostTest.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'. Cannot find or open the PDB file.
'BoostTest.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp110d.dll'. Symbols loaded.
'BoostTest.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr110d.dll'. Symbols loaded.
First-chance exception at 0x6B59DF8D (msvcr110.dll) in BoostTest.exe: 0xC0000005: Access violation reading location 0x9BF7B7A1.
Unhandled exception at 0x6B59DF8D (msvcr110.dll) in BoostTest.exe: 0xC0000005: Access violation reading location 0x9BF7B7A1.
The program '[5292] BoostTest.exe' has exited with code 0 (0x0).

My platform is windows 7 64 bit with visual studio 2012 64 bit compiler.

I have only ever developed on linux and mingw so it is likely me linking something incorrectly or something like that - maybe architecture problems (although I was under the impressions 32 bit applications used 32 bit libraries). Any help appreciated!

Ell
  • 4,238
  • 6
  • 34
  • 60

1 Answers1

0

this isn't an answer to solve the problem you have posted, but will at least help (I hope) by confirming that I Built your posted example and it worked with 32bit libs:

Hello World! 

"C:\Users\john\Documents\Visual Studio 2012\Projects\TestOperator\TestOperator\Debug" 
"C:\Users\john\Documents\Visual Studio 2012\Projects\TestOperator\TestOperator\ReadMe.txt"
"C:\Users\john\Documents\Visual Studio 2012\Projects\TestOperator\TestOperator\stdafx.cpp" 
"C:\Users\john\Documents\Visual Studio 2012\Projects\TestOperator\TestOperator\stdafx.h" 
"C:\Users\john\Documents\Visual Studio 2012\Projects\TestOperator\TestOperator\targetver.h"
 "C:\Users\john\Documents\Visual Studio 2012\Projects\TestOperator\TestOperator\TestOperator.cpp" 
"C:\Users\john\Documents\Visual Studio 2012\Projects\TestOperator\TestOperator\TestOperator.vcxproj"
 "C:\Users\john\Documents\Visual Studio 2012\Projects\TestOperator\TestOperator\TestOperator.vcxproj.filters"

I downloaded the libs (32/64) from the site you quoted above, and I got link errors with the 64bit versions as per This. (I have 64bit OS, compiler etc. ) When I linked with the 32bit version it all worked fine as above.

The warnings you get regarding the PDB files are just messages saying that debug info isn't avaliable in these libs/dlls - so basically no, in principle , you aren't doing anything wrong I think.

If Boost is throwing an exception then you may get some more info using this:

#include <boost/exception/diagnostic_information.hpp>

...

catch(...)
{
    std::cerr << "Unhandled exception!" << std::endl <<
    boost::current_exception_diagnostic_information();
    return 0;
}

One last thing that might help is to add

#define BOOST_LIB_DIAGNOSTIC

To the beginning of the main cpp file and look at the output window to see exactly what libs are being linked E.G.:

1>  stdafx.cpp
1>  TestOperator.cpp
1>  Linking to lib file: libboost_system-vc110-mt-gd-1_52.lib
1>  Linking to lib file: libboost_filesystem-vc110-mt-gd-1_52.lib
1>  TestOperator.vcxproj -> C:\Users\john\Documents\Visual Studio 2012\Projects\TestOperator\Debug\TestOperator.exe
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
Community
  • 1
  • 1
Caribou
  • 2,070
  • 13
  • 29