开发者

Magick++ in VS2010 - unresolved external symbol

开发者 https://www.devze.com 2023-02-01 02:42 出处:网络
I\'m trying to use ImageMagick Magick++ for a C++ Project in VS2010. I installed the Library from here: klick

I'm trying to use ImageMagick Magick++ for a C++ Project in VS2010. I installed the Library from here: klick

Then in my Project, I added c:/program files/ImageMagick-6.6.6-Q16/include to the include folders. Then I tried to use Magick++ with this code:

#include <Magick++.h>
void main(int argc, char ** argv){
    InitializeMagick(*argv);
}

But this does not work! VS2010 returns the following errors:

error LNK2001: unresolved external symbol "__declspec(dllimport) void __cdecl    Magick::InitializeMagick(char const *)" (__imp_?InitializeMagick@Magick@@YAXPBD@Z)
error LNK1120: 1 unresolved externals

What am I doing wrong?

Thanks very much for your help!

UPDATE:

Set Linker -> Input -> Additionnal Dependencies to:

kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;CORE_RL_Magick++_.lib

And Linker -> General -> Additionnal Library Directories to:

C:\Program Files\ImageMagick-6.6.6-Q16\lib

It开发者_C百科 still results in the same error...

UPDATE 2

Opening the .lib files in C:\Program Files\ImageMagick-6.6.6-Q16\lib results in this error:

Magick++ in VS2010 - unresolved external symbol

UPDATE 3

CORE_RL_Magick++_.lib does contain ?InitializeMagick@Magick@@YAXPEBD@Z, but not ?InitializeMagick@Magick@@YAXPBD@Z. Does this mean the .lib file is corrupted?

UPDATE 4

I solved my problem by manually compliling the .lib files. Thanks to all!


CORE_RL_Magick++_.lib does contain ?InitializeMagick@Magick@@YAXPEBD@Z, but not ?InitializeMagick@Magick@@YAXPBD@Z

Using the undname.exe utility, these names undecorate to:

void __cdecl Magick::InitializeMagick(char const *)
void __cdecl Magick::InitializeMagick(char const * __ptr64)

Note the __ptr64 declarator you got on the argument. You've got some kind of compile setting that turns that char* into a 64-bit pointer. Like compiling this code targeting a 64-bit operating system. But linking the 32-bit .lib. This normally generates a linker error about the bit-ness of the .lib being wrong, not so sure why you don't see this. Maybe a mingw artifact, not sure how it works.


You should also indicate to Visual Studio the .lib to be used for linking

in Linker -> Input -> Additionnal Dependencies

EDIT: and put the path of the magick library

in Linker -> General -> Additionnal Library Directories

EDIT2: if it still doesnt work, then you are calling a fonction with a wrong exported signature. Launch the msdev tool Dependency Walker. And check if the magick.lib really exports the function whose name is ?InitializeMagick@Magick@@YAXPBD@Z

I am wrong it's not a microsoft tool: Dependency Walker

I was wrong Dependency Walker doesnt open .lib, only Dlls and Exes. However since you have found ?InitializeMagick@Magick@@YAXPBD@Z in the content of the .lib file, it means that it is reaaly exported this way.

EDIT3: Are you SURE the name and the folder of the additionnal library is correct. I really cannot think of another reason for Visual C++ being unable to link with your library. If your .lib DO contains the string ?InitializeMagick@Magick@@YAXPBD@Z I really think it should link.

EDIT4: could you paste from the file <Magick++.h> the prototype definition of InitializeMagick ? there is something that makes it be compiled differently between visual c++ and your library supplier. ?InitializeMagick@Magick@@YAXPEBD@Z and ?InitializeMagick@Magick@@YAXPEBD@Z are two DIFFERENT signatures. When including <Magick++.h> Visual C++ understands its differently. (that's why I need to see the prototype of the function)


You should also indicate to Visual Studio the .lib to be used for linking in Linker -> Input -> Additionnal Dependencies

Thank you! The additional dependecies line contains now the following text (look at the end): kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;C:\Program Files\ImageMagick-6.6.6-Q16\lib\CORE_RL_Magick++_.lib

It still does not work. Is it the wrong .lib file?

what is this .lib file for? Shouldn't source code just work? There isn't any DLL...


The documentation says: "Windows users may get started by manually editing a project file for one of the Magick++ demo programs." Did you try that?

0

精彩评论

暂无评论...
验证码 换一张
取 消