Help with Access Violation in simple serialization

Hi there, I am having some serious problems when trying to instantiate either a boost::archive::xml_oarchive or a boost::archive::text_oarchive: everytime I receive an "Unhandled exception at XXX (msvcr90d.dll) in XXX : Access violation writing location" I have simplified a test case up to this: structure I want to save (in whatever.h): typedef struct s_pt { int x; int y; bool operator< (const struct s_pt &spt2) const { return (x < spt2.x) && (y < spt2.y); } bool operator== (const struct s_pt &spt2) const { return (x == spt2.x) && (y == spt2.y); } template<class Archive> // turns into a serializable component void serialize(Archive &ar, const unsigned int version) { using boost::serialization::make_nvp; ar & make_nvp("x", x); ar & make_nvp("y", y); } } POINT2D; saving routine in main.cpp std::ofstream ofs("savedProject.imag3d"); boost::archive::xml_oarchive oa(ofs); const structs::POINT2D p = {111, 222}; oa << boost::serialization::make_nvp("p2d", p); but I get this error in boost::archive::xml_oarchive oa(ofs); I have tried already both xml_oarchive and text_oarchive... but the demo.cpp provided by http://www.boost.org/doc/libs/1_35_0/libs/serialization/doc/index.html involving the bus routes works!!! what am I doing wrong??? I use Visual Studio 2008. Thanks in advance, Tiago

I am linking to the following libs in my project: glut32.lib glu32.lib opengl32.lib odbc32.lib odbccp32.lib cv.lib cxcore.lib highgui.lib basically OpenGL and OpenCV. Are there any imcompatibility issues? I simply CANNOT instantiate an output file!!!. Thanks in advance, Tiago On Tue, Jul 15, 2008 at 11:21 AM, Tiago da Silva <besbatti@gmail.com> wrote:
Hi there,
I am having some serious problems when trying to instantiate either a boost::archive::xml_oarchive or a boost::archive::text_oarchive: everytime I receive an
"Unhandled exception at XXX (msvcr90d.dll) in XXX : Access violation writing location"
I have simplified a test case up to this:
structure I want to save (in whatever.h):
typedef struct s_pt { int x; int y;
bool operator< (const struct s_pt &spt2) const { return (x < spt2.x) && (y < spt2.y); }
bool operator== (const struct s_pt &spt2) const { return (x == spt2.x) && (y == spt2.y); }
template<class Archive> // turns into a serializable component void serialize(Archive &ar, const unsigned int version) { using boost::serialization::make_nvp;
ar & make_nvp("x", x); ar & make_nvp("y", y); }
} POINT2D;
saving routine in main.cpp
std::ofstream ofs("savedProject.imag3d");
boost::archive::xml_oarchive oa(ofs);
const structs::POINT2D p = {111, 222};
oa << boost::serialization::make_nvp("p2d", p);
but I get this error in
boost::archive::xml_oarchive oa(ofs);
I have tried already both xml_oarchive and text_oarchive... but the demo.cpp provided by
http://www.boost.org/doc/libs/1_35_0/libs/serialization/doc/index.html
involving the bus routes works!!!
what am I doing wrong???
I use Visual Studio 2008.
Thanks in advance,
Tiago

Tiago da Silva escribió:
I am linking to the following libs in my project:
glut32.lib glu32.lib opengl32.lib odbc32.lib odbccp32.lib cv.lib cxcore.lib highgui.lib
basically OpenGL and OpenCV.
Are there any imcompatibility issues? I simply CANNOT instantiate an output file!!!.
Hi Tiago, Have you made sure that all the libs your're using, as well as the main program, are built to work with the same version of the C runtime library (dynamic/static, multi/single-threaded)? Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

Thx for answering, Joaquín. Currently I'm using a Multi-threaded Debug DLL (/MDd) runtime, without optimizations, and all of them work perfectly. No warnings. So, do you think that, by changing the runtime options, it might work? Tiago On Tue, Jul 15, 2008 at 10:58 PM, <joaquin@tid.es> wrote:
Tiago da Silva escribió:
I am linking to the following libs in my project:
glut32.lib glu32.lib opengl32.lib odbc32.lib odbccp32.lib cv.lib cxcore.lib highgui.lib
basically OpenGL and OpenCV.
Are there any imcompatibility issues? I simply CANNOT instantiate an output file!!!.
Hi Tiago,
Have you made sure that all the libs your're using, as well as the main program, are built to work with the same version of the C runtime library (dynamic/static, multi/single-threaded)?
Joaquín M López Muñoz Telefónica, Investigación y Desarrollo _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

I tried all the combinations available, and mylibs require me to use a Multithreaded DLL runtime... still getting the Access violation writing location when I try to instantiate a [code] boost::archive::text_oarchive oa(ofs) [/code] (ofs being a ofstream)... one thing i noticed is that if I do this: [code] stringstream archbuf; boost::archive::text_oarchive *oa = new boost::archive::text_oarchive(archbuf, 3 ); *oa << VerticesKeeper::getConst( vkeeper ); archbuf.flush(); delete oa; [/code] I don't get the error, but the file is not written ( that is, the archbuf.flush() has no effect at all). Any other ideas? Thanks in advance, Tiago On Wed, Jul 16, 2008 at 12:17 AM, Tiago da Silva <besbatti@gmail.com> wrote:
Thx for answering, Joaquín.
Currently I'm using a Multi-threaded Debug DLL (/MDd) runtime, without optimizations, and all of them work perfectly. No warnings.
So, do you think that, by changing the runtime options, it might work?
Tiago
On Tue, Jul 15, 2008 at 10:58 PM, <joaquin@tid.es> wrote:
Tiago da Silva escribió:
I am linking to the following libs in my project:
glut32.lib glu32.lib opengl32.lib odbc32.lib odbccp32.lib cv.lib cxcore.lib highgui.lib
basically OpenGL and OpenCV.
Are there any imcompatibility issues? I simply CANNOT instantiate an output file!!!.
Hi Tiago,
Have you made sure that all the libs your're using, as well as the main program, are built to work with the same version of the C runtime library (dynamic/static, multi/single-threaded)?
Joaquín M López Muñoz Telefónica, Investigación y Desarrollo _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Here is how I managed not to correct, but to work around my bug: [code] stringstream archbuf; boost::archive::text_oarchive *oa = new boost::archive::text_oarchive(archbuf, 3 ); const structs::POINT2D aaa = {1,2,3,4}; const structs::LIVE_CAM aaumalivec = {5, 6, 7, 8, 9}; const structs::POINT2D_PAIR aappp = {10, 11, 12, 13, 14, 15, 16, 17}; const string anana = "ana acaxa kkk"; *oa << aaa; *oa << aaumalivec; *oa << anana; *oa << aappp; std::cout << "-- archive content: >" << archbuf.str() << endl; // archbuf.flush(); ofstream ofs("savedProject.imag3d"); ofs << archbuf.str(); ofs.close(); delete oa; [/code] basically, I use boost to serialize everything inside a stringbuffer, and then I write the whole string buffer to a file. Tiago On Wed, Jul 16, 2008 at 12:34 AM, Tiago da Silva <besbatti@gmail.com> wrote:
I tried all the combinations available, and mylibs require me to use a Multithreaded DLL runtime...
still getting the Access violation writing location when I try to instantiate a
[code]
boost::archive::text_oarchive oa(ofs)
[/code]
(ofs being a ofstream)...
one thing i noticed is that if I do this:
[code]
stringstream archbuf; boost::archive::text_oarchive *oa = new boost::archive::text_oarchive(archbuf, 3 );
*oa << VerticesKeeper::getConst( vkeeper );
archbuf.flush(); delete oa;
[/code]
I don't get the error, but the file is not written ( that is, the archbuf.flush() has no effect at all).
Any other ideas?
Thanks in advance,
Tiago
On Wed, Jul 16, 2008 at 12:17 AM, Tiago da Silva <besbatti@gmail.com> wrote:
Thx for answering, Joaquín.
Currently I'm using a Multi-threaded Debug DLL (/MDd) runtime, without optimizations, and all of them work perfectly. No warnings.
So, do you think that, by changing the runtime options, it might work?
Tiago
On Tue, Jul 15, 2008 at 10:58 PM, <joaquin@tid.es> wrote:
Tiago da Silva escribió:
I am linking to the following libs in my project:
glut32.lib glu32.lib opengl32.lib odbc32.lib odbccp32.lib cv.lib cxcore.lib highgui.lib
basically OpenGL and OpenCV.
Are there any imcompatibility issues? I simply CANNOT instantiate an output file!!!.
Hi Tiago,
Have you made sure that all the libs your're using, as well as the main program, are built to work with the same version of the C runtime library (dynamic/static, multi/single-threaded)?
Joaquín M López Muñoz Telefónica, Investigación y Desarrollo _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

start with one of the demos or examples and make sure you can build and execute it. In fact, you should run the whole test suite. Look for library_status and library_test.sh and library_test.bat Robert Ramey Tiago da Silva wrote:
Here is how I managed not to correct, but to work around my bug:
[code]
stringstream archbuf; boost::archive::text_oarchive *oa = new boost::archive::text_oarchive(archbuf, 3 );
const structs::POINT2D aaa = {1,2,3,4}; const structs::LIVE_CAM aaumalivec = {5, 6, 7, 8, 9}; const structs::POINT2D_PAIR aappp = {10, 11, 12, 13, 14, 15, 16, 17};
const string anana = "ana acaxa kkk";
*oa << aaa; *oa << aaumalivec; *oa << anana; *oa << aappp;
std::cout << "-- archive content: >" << archbuf.str() << endl;
// archbuf.flush();
ofstream ofs("savedProject.imag3d");
ofs << archbuf.str();
ofs.close();
delete oa;
[/code]
basically, I use boost to serialize everything inside a stringbuffer, and then I write the whole string buffer to a file.
Tiago
On Wed, Jul 16, 2008 at 12:34 AM, Tiago da Silva <besbatti@gmail.com> wrote:
I tried all the combinations available, and mylibs require me to use a Multithreaded DLL runtime...
still getting the Access violation writing location when I try to instantiate a
[code]
boost::archive::text_oarchive oa(ofs)
[/code]
(ofs being a ofstream)...
one thing i noticed is that if I do this:
[code]
stringstream archbuf; boost::archive::text_oarchive *oa = new boost::archive::text_oarchive(archbuf, 3 );
*oa << VerticesKeeper::getConst( vkeeper );
archbuf.flush(); delete oa;
[/code]
I don't get the error, but the file is not written ( that is, the archbuf.flush() has no effect at all).
Any other ideas?
Thanks in advance,
Tiago
On Wed, Jul 16, 2008 at 12:17 AM, Tiago da Silva <besbatti@gmail.com> wrote:
Thx for answering, Joaquín.
Currently I'm using a Multi-threaded Debug DLL (/MDd) runtime, without optimizations, and all of them work perfectly. No warnings.
So, do you think that, by changing the runtime options, it might work?
Tiago
On Tue, Jul 15, 2008 at 10:58 PM, <joaquin@tid.es> wrote:
Tiago da Silva escribió:
I am linking to the following libs in my project:
glut32.lib glu32.lib opengl32.lib odbc32.lib odbccp32.lib cv.lib cxcore.lib highgui.lib
basically OpenGL and OpenCV.
Are there any imcompatibility issues? I simply CANNOT instantiate an output file!!!.
Hi Tiago,
Have you made sure that all the libs your're using, as well as the main program, are built to work with the same version of the C runtime library (dynamic/static, multi/single-threaded)?
Joaquín M López Muñoz Telefónica, Investigación y Desarrollo _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

That's what I did... I played a lot with the serialization demos provided in the instalation package, and they all work perfectly well... it's something in my project that has a conflict with the boost library, and I gave up of trying to figure it out... I'll stick with my workaround... Tiago On Wed, Jul 16, 2008 at 5:17 PM, Robert Ramey <ramey@rrsd.com> wrote:
start with one of the demos or examples and make sure you can build and execute it. In fact, you should run the whole test suite. Look for library_status and library_test.sh and library_test.bat
Robert Ramey
Tiago da Silva wrote:
Here is how I managed not to correct, but to work around my bug:
[code]
stringstream archbuf; boost::archive::text_oarchive *oa = new boost::archive::text_oarchive(archbuf, 3 );
const structs::POINT2D aaa = {1,2,3,4}; const structs::LIVE_CAM aaumalivec = {5, 6, 7, 8, 9}; const structs::POINT2D_PAIR aappp = {10, 11, 12, 13, 14, 15, 16, 17};
const string anana = "ana acaxa kkk";
*oa << aaa; *oa << aaumalivec; *oa << anana; *oa << aappp;
std::cout << "-- archive content: >" << archbuf.str() << endl;
// archbuf.flush();
ofstream ofs("savedProject.imag3d");
ofs << archbuf.str();
ofs.close();
delete oa;
[/code]
basically, I use boost to serialize everything inside a stringbuffer, and then I write the whole string buffer to a file.
Tiago
On Wed, Jul 16, 2008 at 12:34 AM, Tiago da Silva <besbatti@gmail.com> wrote:
I tried all the combinations available, and mylibs require me to use a Multithreaded DLL runtime...
still getting the Access violation writing location when I try to instantiate a
[code]
boost::archive::text_oarchive oa(ofs)
[/code]
(ofs being a ofstream)...
one thing i noticed is that if I do this:
[code]
stringstream archbuf; boost::archive::text_oarchive *oa = new boost::archive::text_oarchive(archbuf, 3 );
*oa << VerticesKeeper::getConst( vkeeper );
archbuf.flush(); delete oa;
[/code]
I don't get the error, but the file is not written ( that is, the archbuf.flush() has no effect at all).
Any other ideas?
Thanks in advance,
Tiago
On Wed, Jul 16, 2008 at 12:17 AM, Tiago da Silva <besbatti@gmail.com> wrote:
Thx for answering, Joaquín.
Currently I'm using a Multi-threaded Debug DLL (/MDd) runtime, without optimizations, and all of them work perfectly. No warnings.
So, do you think that, by changing the runtime options, it might work?
Tiago
On Tue, Jul 15, 2008 at 10:58 PM, <joaquin@tid.es> wrote:
Tiago da Silva escribió:
I am linking to the following libs in my project:
glut32.lib glu32.lib opengl32.lib odbc32.lib odbccp32.lib cv.lib cxcore.lib highgui.lib
basically OpenGL and OpenCV.
Are there any imcompatibility issues? I simply CANNOT instantiate an output file!!!.
Hi Tiago,
Have you made sure that all the libs your're using, as well as the main program, are built to work with the same version of the C runtime library (dynamic/static, multi/single-threaded)?
Joaquín M López Muñoz Telefónica, Investigación y Desarrollo _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (3)
-
joaquin@tid.es
-
Robert Ramey
-
Tiago da Silva