Issue with CRT/std::string

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
dsharlet

Issue with CRT/std::string

Post by dsharlet »

Any time I try to load an image from a file, i.e.:

Magick::Image("C:\\Test.bmp")

It crashes in std::string related functions. I think the problem is that it looks like the library was compiled with MSVCRT 7.1, while I am using 8.

I need a workaround for this problem. I don't see a plain old char pointer member, so it looks like my next best option is to load the file into a Blob myself (so I can open the file with my version of the CRT), and then pass the blob to the Magick::Image constructor instead of the filename.

My question is that I need this to be relatively fast (I am dealing with image sequences of movies), is this going to be significantly slower than the method of passing the string and having the library do the work? Will I be sacrificing functionality by doing this? I need some of the more exotic image types to work (exr, dpx) so I need all the formats to support working with blobs.

A cursory look at the source of Image.cpp did not reveal whether there would be a difference between the two.

edit: I went ahead and implemented this workaround, and it works. This tells me that it most likely is the source of the crash. So all I need to know is that I'm not losing functionality or performance by doing this.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Issue with CRT/std::string

Post by magick »

Try building the button project in ImageMagick-6.4.4-Q16\Magick_demos. Now modify it slightly to call Magick::Image("C:\\Test.bmp"). Does that work? Its possible that certain project options need to be set for Magick++ to work properly.
dsharlet

Re: Issue with CRT/std::string

Post by dsharlet »

That test crashes (I tried it earlier).

My project is huge, and most of the compiler options are set the way they are so the rest of my project (and other libraries) work.

Regardless, I don't think the compiler options would fix the problem. The issue is deeper than that - that the declaration (memory layout) of std::string changed between MSVCRT 7.1 and MSVCRT 8.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Issue with CRT/std::string

Post by magick »

The obvious solution would be to compile the ImageMagick distribution with Visual 8. Just grab the ImageMagick Windows source distribution and run the configure program to generate a workspace.
dsharlet

Re: Issue with CRT/std::string

Post by dsharlet »

But ImageMagick is client installed software.

I am OK with the solution I have (read/write blobs from/to files manually, then pass that to Image), as long as I am not losing the support of image file formats (if ImageMagick is using other libraries to support formats that don't support reading/writing from memory).
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Issue with CRT/std::string

Post by magick »

Blob support is automagically available to all image formats and delegates.
Post Reply