0
votes

I downloaded and compiled GraphicsMagick, 1.3.23, Q16, x64, StaticMT version. I had to convert the Visual Studio 7 solution generated by GraphicsMagick's build utility to Visual Studio 2015 format. I linked my project to CORE_DB_magick_.lib and CORE_DB_Magick++_.lib.

When the linker ran, it produced unresolved external symbols when linking InitializeMagick() and DestroyMagick()

1>wtd.lib(WebController.obj) : error LNK2019: unresolved external symbol __imp_DestroyMagick referenced in function "public: __cdecl Wt::WebController::~WebController(void)" (??1WebController@Wt@@QEAA@XZ)
1>wtd.lib(WebController.obj) : error LNK2019: unresolved external symbol __imp_InitializeMagick referenced in function "public: __cdecl Wt::WebController::WebController(class Wt::WServer &,class std::basic_string,class std::allocator > const &,bool)" (??0WebController@Wt@@QEAA@AEAVWServer@1@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_N@Z)

I can't understand why the symbols are not being linked. Any ideas?

2

2 Answers

0
votes

Apparently, GraphicsMagick Static versions do not link properly.

0
votes

What is your project type? I had a similar problem when trying to link the GraphicsMagick libraries to a DLL.

The clue here is that __imp is the function decoration for DLL imports, so you're trying to link with DLL functions.

The problem is that the header magick/common.h, when linked to a DLL project, reads the current configuration of the Visual Studio pre-processor environment to determine which mode the library is in, which is obviously wrong if you're trying to link static libraries into your DLL, for example. In this case, it defines MagickExport to __declspec(dllimport).

AFAIK this is a bug in the library. For proper static build support, magick/common.h needs to do something like read information from the magick/magick_config.h to determine what mode the library was actually built in and define MagickExport appropriately.

Since your library is statically linked, you can fix this by commenting out everything in the define:

#if defined(MSWINDOWS) && !defined(__CYGWIN__)

and replacing it with:

#define MagickExport
#define ModuleExport
#define MagickGlobal