New to Magick++ , sample code crashes without error message

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
graphicsRat
Posts: 3
Joined: 2011-05-06T16:16:25-07:00
Authentication code: 8675308

New to Magick++ , sample code crashes without error message

Post by graphicsRat »

I'm only just trying to get the hang of Magic++ and trying out the following bit of code (in Visual Studio .NET 2003). The code compiles OK but crashes without any error when I run it. BTW, I'm using the development headers and lib files that come with the precompiled Windows binary.

Edit: when I ran the program though a debugger I found that Image::write() causes "unhandled exception".

Code: Select all

#include <Magick++/Image.h>
#include <Magick++/Include.h>
#include <Magick++/Color.h>
#include <Magick++/Geometry.h>
#include <iostream> 

int main( int argc , char* argv[] )
{
	try
	{ 
		Magick::Geometry dimensions( 256 , 256 );
		Magick::ColorRGB color( 0 , 0 , 0 );

		Magick::Image newImage( dimensions , color );
		newImage.write( "demo.png" );
	}
	catch( Magick::Exception &error_ )
	{
		std::cout << "Caught exception: " << error_.what() << std::endl;
		return 1;
	} 
	return 0;
}
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: New to Magick++ , sample code crashes without error mess

Post by magick »

Do you choose the Release build rather than the default Debug build?
graphicsRat
Posts: 3
Joined: 2011-05-06T16:16:25-07:00
Authentication code: 8675308

Re: New to Magick++ , sample code crashes without error mess

Post by graphicsRat »

magick wrote:Do you choose the Release build rather than the default Debug build?
Thanks. I was developing in Debug mode and now I've switched to Release mode. Unfortunately, compiling in Release mode, Single-threaded (/ML), produces a slew of linker errors:

Code: Select all

ImageMagicTest.obj : error LNK2019: unresolved external symbol "public: __thiscall Magick::Geometry::~Geometry(void)" (??1Geometry@Magick@@QAE@XZ) referenced in function _main
ImageMagicTest.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall Magick::ColorRGB::~ColorRGB(void)" (??1ColorRGB@Magick@@UAE@XZ) referenced in function _main
ImageMagicTest.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall Magick::Image::~Image(void)" (??1Image@Magick@@UAE@XZ) referenced in function _main
ImageMagicTest.obj : error LNK2019: unresolved external symbol "public: void __thiscall Magick::Image::write(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?write@Image@Magick@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main
ImageMagicTest.obj : error LNK2019: unresolved external symbol "public: __thiscall Magick::Image::Image(class Magick::Geometry const &,class Magick::Color const &)" (??0Image@Magick@@QAE@ABVGeometry@1@ABVColor@1@@Z) referenced in function _main
ImageMagicTest.obj : error LNK2019: unresolved external symbol "public: __thiscall Magick::ColorRGB::ColorRGB(double,double,double)" (??0ColorRGB@Magick@@QAE@NNN@Z) referenced in function _main
ImageMagicTest.obj : error LNK2019: unresolved external symbol "public: __thiscall Magick::Geometry::Geometry(unsigned int,unsigned int,long,long,bool,bool)" (??0Geometry@Magick@@QAE@IIJJ_N0@Z) referenced in function _main
Release/TestBed.exe : fatal error LNK1120: 7 unresolved externals
Thinking the problem was because the prebuilt version binary was not distributed did not contain all the required libraries I tried compiling the whole all of Magick under Visual Studio .NET (2003), and it pretty much went well with the exception of the following two linker errors

Code: Select all

   Creating library ..\lib\CORE_DB_magick_.lib and object ..\lib\CORE_DB_magick_.exp
blob.obj : error LNK2019: unresolved external symbol __fseek referenced in function _SeekBlob
blob.obj : error LNK2019: unresolved external symbol __ftell referenced in function _TellBlob
..\bin\CORE_DB_magick_.dll : fatal error LNK1120: 2 unresolved externa

Code: Select all

MagickCore lib DLL import interface
MagickCore module DLL export interface
\Downloads\src\ImageMagick-6.6.9-8-windows\ImageMagick-6.6.9\coders\tiff.c(354) : warning C4013: '_ftell' undefined; assuming extern returning int
\Downloads\src\ImageMagick-6.6.9-8-windows\ImageMagick-6.6.9\coders\tiff.c(365) : warning C4013: '_fseek' undefined; assuming extern returning int
Linking...
   Creating library ..\lib\IM_MOD_DB_tiff_.lib and object ..\lib\IM_MOD_DB_tiff_.exp
tiff.obj : error LNK2019: unresolved external symbol __fseek referenced in function _ReadGROUP4Image
tiff.obj : error LNK2019: unresolved external symbol __ftell referenced in function _ReadGROUP4Image
Last edited by graphicsRat on 2011-05-07T08:53:12-07:00, edited 1 time in total.
graphicsRat
Posts: 3
Joined: 2011-05-06T16:16:25-07:00
Authentication code: 8675308

Re: New to Magick++ , sample code crashes without error mess

Post by graphicsRat »

I've tried compiling my sample code in Release mode with the Multi-threaded DLL (/MD) option, but got the following error

Code: Select all

Compiling...
ImageMagicTest.cpp
C:\Program Files\ImageMagick-6.6.9-Q16\include\Magick++\Drawable.h(456) : warning C4251: 'Magick::DrawableBezier::_coordinates' : class 'std::list<_Ty>' needs to have dll-interface to be used by clients of class 'Magick::DrawableBezier'
        with
        [
            _Ty=Magick::Coordinate
        ]
C:\Program Files\ImageMagick-6.6.9-Q16\include\Magick++\Drawable.h(1128) : warning C4251: 'Magick::DrawablePath::_path' : class 'std::list<_Ty>' needs to have dll-interface to be used by clients of class 'Magick::DrawablePath'
        with
        [
            _Ty=Magick::VPath
        ]
C:\Program Files\ImageMagick-6.6.9-Q16\include\Magick++\Drawable.h(1217) : warning C4251: 'Magick::DrawablePolygon::_coordinates' : class 'std::list<_Ty>' needs to have dll-interface to be used by clients of class 'Magick::DrawablePolygon'
        with
        [
            _Ty=Magick::Coordinate
        ]
C:\Program Files\ImageMagick-6.6.9-Q16\include\Magick++\Drawable.h(1237) : warning C4251: 'Magick::DrawablePolyline::_coordinates' : class 'std::list<_Ty>' needs to have dll-interface to be used by clients of class 'Magick::DrawablePolyline'
        with
        [
            _Ty=Magick::Coordinate
        ]
C:\Program Files\ImageMagick-6.6.9-Q16\include\Magick++\Drawable.h(2255) : warning C4251: 'Magick::PathArcAbs::_coordinates' : class 'std::list<_Ty>' needs to have dll-interface to be used by clients of class 'Magick::PathArcAbs'
        with
        [
            _Ty=Magick::PathArcArgs
        ]
C:\Program Files\ImageMagick-6.6.9-Q16\include\Magick++\Drawable.h(2277) : warning C4251: 'Magick::PathArcRel::_coordinates' : class 'std::list<_Ty>' needs to have dll-interface to be used by clients of class 'Magick::PathArcRel'
        with
        [
            _Ty=Magick::PathArcArgs
        ]
C:\Program Files\ImageMagick-6.6.9-Q16\include\Magick++\Drawable.h(2428) : warning C4251: 'Magick::PathCurvetoAbs::_args' : class 'std::list<_Ty>' needs to have dll-interface to be used by clients of class 'Magick::PathCurvetoAbs'
        with
        [
            _Ty=Magick::PathCurvetoArgs
        ]
C:\Program Files\ImageMagick-6.6.9-Q16\include\Magick++\Drawable.h(2451) : warning C4251: 'Magick::PathCurvetoRel::_args' : class 'std::list<_Ty>' needs to have dll-interface to be used by clients of class 'Magick::PathCurvetoRel'
        with
        [
            _Ty=Magick::PathCurvetoArgs
        ]
C:\Program Files\ImageMagick-6.6.9-Q16\include\Magick++\Drawable.h(2475) : warning C4251: 'Magick::PathSmoothCurvetoAbs::_coordinates' : class 'std::list<_Ty>' needs to have dll-interface to be used by clients of class 'Magick::PathSmoothCurvetoAbs'
        with
        [
            _Ty=Magick::Coordinate
        ]
C:\Program Files\ImageMagick-6.6.9-Q16\include\Magick++\Drawable.h(2500) : warning C4251: 'Magick::PathSmoothCurvetoRel::_coordinates' : class 'std::list<_Ty>' needs to have dll-interface to be used by clients of class 'Magick::PathSmoothCurvetoRel'
        with
        [
            _Ty=Magick::Coordinate
        ]
C:\Program Files\ImageMagick-6.6.9-Q16\include\Magick++\Drawable.h(2609) : warning C4251: 'Magick::PathQuadraticCurvetoAbs::_args' : class 'std::list<_Ty>' needs to have dll-interface to be used by clients of class 'Magick::PathQuadraticCurvetoAbs'
        with
        [
            _Ty=Magick::PathQuadraticCurvetoArgs
        ]
C:\Program Files\ImageMagick-6.6.9-Q16\include\Magick++\Drawable.h(2633) : warning C4251: 'Magick::PathQuadraticCurvetoRel::_args' : class 'std::list<_Ty>' needs to have dll-interface to be used by clients of class 'Magick::PathQuadraticCurvetoRel'
        with
        [
            _Ty=Magick::PathQuadraticCurvetoArgs
        ]
C:\Program Files\ImageMagick-6.6.9-Q16\include\Magick++\Drawable.h(2657) : warning C4251: 'Magick::PathSmoothQuadraticCurvetoAbs::_coordinates' : class 'std::list<_Ty>' needs to have dll-interface to be used by clients of class 'Magick::PathSmoothQuadraticCurvetoAbs'
        with
        [
            _Ty=Magick::Coordinate
        ]
C:\Program Files\ImageMagick-6.6.9-Q16\include\Magick++\Drawable.h(2681) : warning C4251: 'Magick::PathSmoothQuadraticCurvetoRel::_coordinates' : class 'std::list<_Ty>' needs to have dll-interface to be used by clients of class 'Magick::PathSmoothQuadraticCurvetoRel'
        with
        [
            _Ty=Magick::Coordinate
        ]
C:\Program Files\ImageMagick-6.6.9-Q16\include\Magick++\Drawable.h(2709) : warning C4251: 'Magick::PathLinetoAbs::_coordinates' : class 'std::list<_Ty>' needs to have dll-interface to be used by clients of class 'Magick::PathLinetoAbs'
        with
        [
            _Ty=Magick::Coordinate
        ]
C:\Program Files\ImageMagick-6.6.9-Q16\include\Magick++\Drawable.h(2733) : warning C4251: 'Magick::PathLinetoRel::_coordinates' : class 'std::list<_Ty>' needs to have dll-interface to be used by clients of class 'Magick::PathLinetoRel'
        with
        [
            _Ty=Magick::Coordinate
        ]
C:\Program Files\ImageMagick-6.6.9-Q16\include\Magick++\Drawable.h(2875) : warning C4251: 'Magick::PathMovetoAbs::_coordinates' : class 'std::list<_Ty>' needs to have dll-interface to be used by clients of class 'Magick::PathMovetoAbs'
        with
        [
            _Ty=Magick::Coordinate
        ]
C:\Program Files\ImageMagick-6.6.9-Q16\include\Magick++\Drawable.h(2899) : warning C4251: 'Magick::PathMovetoRel::_coordinates' : class 'std::list<_Ty>' needs to have dll-interface to be used by clients of class 'Magick::PathMovetoRel'
        with
        [
            _Ty=Magick::Coordinate
        ]
Linking...
ImageMagicTest.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall Magick::Geometry::~Geometry(void)" (__imp_??1Geometry@Magick@@QAE@XZ) referenced in function _main
ImageMagicTest.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall Magick::ColorRGB::~ColorRGB(void)" (__imp_??1ColorRGB@Magick@@UAE@XZ) referenced in function _main
ImageMagicTest.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall Magick::Image::~Image(void)" (__imp_??1Image@Magick@@UAE@XZ) referenced in function _main
ImageMagicTest.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall Magick::Image::write(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_?write@Image@Magick@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main
ImageMagicTest.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall Magick::Image::Image(class Magick::Geometry const &,class Magick::Color const &)" (__imp_??0Image@Magick@@QAE@ABVGeometry@1@ABVColor@1@@Z) referenced in function _main
ImageMagicTest.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall Magick::ColorRGB::ColorRGB(double,double,double)" (__imp_??0ColorRGB@Magick@@QAE@NNN@Z) referenced in function _main
ImageMagicTest.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall Magick::Geometry::Geometry(unsigned int,unsigned int,long,long,bool,bool)" (__imp_??0Geometry@Magick@@QAE@IIJJ_N0@Z) referenced in function _main
Release/TestBed.exe : fatal error LNK1120: 7 unresolved externals
BTW, I've tried compiling the entire library in both Debug and Release mode and both times I got the error "unresolved external symbol __fseek" and "unresolved external symbol __ftell"
Post Reply