Magick ++ in VS2010 - unresolved external character

I am trying to use ImageMagick Magick ++ for a C ++ project in VS2010. I installed the library here: klick

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

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

But that will 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?

Many thanks for your help!

UPDATE:

Install Linker -> Input -> Additionnal Dependencies for:

 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 β†’ Additive Library Directories:

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

This still leads to the same error ...

UPDATE 2

Opening .lib files in C: \ Program Files \ ImageMagick-6.6.6-Q16 \ lib leads to an error: alt text

UPDATE 3

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

UPDATE 4

I solved my problem by manually compiling .lib files. Thanks everyone!

+5
source share
4 answers

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

Using the undname.exe utility, these names will not point to:

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

Pay attention to the __ptr64 declarator, which you received by argument. You have some kind of compilation option that turns this char * into a 64-bit pointer. Like compiling this code for a 64-bit operating system. But linking a 32 bit .lib. Usually this generates a linker error that the .lib bit error is incorrect, not so sure why you do not see it. Maybe an artifact, but not sure how this works.

+3
source

You must also specify Visual Studio .lib for the link.

in Linker β†’ Input β†’ Additionnal Dependencies

EDIT: and put the path into the magic library

at Linker β†’ General β†’ Additive Library Directories

EDIT2: if it still does not work, you call the phrase with the wrong exported signature. Run the msdev Dependency Walker tool. And check if magick.lib really exports a function whose name is ?InitializeMagick@Magick @@ YAXPBD@Z

I'm wrong, this is not a tool for Microsoft: Dependency Walker

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

EDIT3: Are you sure the name and folder of the secondary library are correct. I really can’t come up with another reason why Visual C ++ cannot contact your library. If your .lib DO contains the string ?InitializeMagick@Magick @@ YAXPBD@Z , I really think it should be referenced.

EDIT4: can you insert the InitializeMagick prototype definition from the <Magick++.h> file? There is something that makes it compiled differently between visual C ++ and your library provider. ?InitializeMagick@Magick @@ YAXPEBD@Z and ?InitializeMagick@Magick @@ YAXPEBD@Z are two DIFFERENT signatures. When you turn on <Magick++.h> Visual C ++ understands it differently. (why do I need to see a function prototype)

+1
source

You must also specify the Visual Studio.lib that will be used for binding in Linker -> Input -> Additionnal Dependencies

Thanks! An additional line of dependecies now contains 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 this the wrong .lib file?

what is the .lib file for? Should the source code work? No dll ...

0
source

Source: https://habr.com/ru/post/1332894/


All Articles