ImageMagick static compilation with another project gives linker errors

China☆狼群 提交于 2019-12-23 11:48:15

问题


I've downloaded the ImageMagick source, compiled the wizard to create a Visual Studio solution for static linkage, and included the static library Magick++ project in my sample project (code below). I've also added a dependency on that project and included the .lib file in the solution, nothing helps.

#include <Magick++.h>

int main()
{
    Magick::Image image;
    bool test = image.isValid();
    return 0;
}

This gives several linker errors, such as:

unresolved external symbol "__declspec(dllimport) public: virtual __thiscall Magick::Image::~Image(void)" (__imp_??1Image@Magick@@UAE@XZ) referenced in function _main

Why can't it find the implementation?

I'm using Visual Studio 2010 Beta 2.


回答1:


The problem may rise from that you are using different compiler than the library was compiled with. As your compiler is fairly new, it's very likely it uses different name mangling and can't find method signatures inside the library.




回答2:


This error is strange - The compiler is looking for a function from a DLL (__declspec(dllimport)). Are you sure you are using the right header files ?



来源:https://stackoverflow.com/questions/2520284/imagemagick-static-compilation-with-another-project-gives-linker-errors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!