尝试使用属性时发生Magick ++链接错误

时间:2019-04-16 05:20:49

标签: visual-studio-2017 magick++

使用Visual Studio 2017 Community Edition和经过验证的C++代码,尝试编译和链接Windows C++ Form应用程序时出现链接错误。

我试图使用Magick ++属性方法从jpeg图像文件中获取exif数据,但是图像对象实例属性出现链接错误LNK2028和LNK2019。 ImageMagick的版本为6.9.3-7,使用Magick ++标头编译。操作系统是Windows10。尝试使用类似编译的Windows最新版本的Image Magick时,我遇到相同的问题。

exif数据可通过Windows命令行找到-verbose文件名。

我正在使用的Magick ++方法,例如读取,质量,调整大小和写入所有链接,并且都可以正常工作,但该属性不能正常运行-(标准字符串)extract_data = image.attribute(“ exif:DateTime”);给出链接错误。

如果我注释掉包含image.attribute语句的代码块,程序将编译,链接并执行OK。

在单独的Windows 7 PC上,相同的C ++代码可以编译,链接和完美执行。在该PC上,IDE是带有ImageMagick 6.8.6的Visual Studio 2010 Express。

已按照上述方法尝试了不同版本的ImageMagick。

Magick::InitializeMagick(NULL);
Magick::Image image;        // create an instance of the Magick::Image class
image.read(std_input_file_name);    // read the selected jpg file into the image object 
... develop the resize parameters (not shown)
image.resize(Magick::Geometry(int_output_width, int_output_height));
... the above works fine.
... but if I include:
std::string extracted_data, date_time_data;
extracted_data = image.attribute("exif:DateTimeOriginal");
... I get the linkage errors    

没有指出编译错误。

我正在尝试摆脱两个链接错误: LNK2028 未解析的令牌(0A00079D)“ public:类std :: basic_string,类std :: allocator> __thiscall Magick :: Image :: attribute(class std :: basic_string,class std :: allocator>)”(?attribute @ Image @ Magick @@ $$ FQAE?AV?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@ V34 @@ Z)在函数“ private:void __clrcall UseLIB ::”中引用Form1 :: btnStart_Click(类系统:: Object ^,类系统:: EventArgs ^)“(?btnStart_Click @ Form1 @ UseLIB @@ $$ FA $ AAMXP $ AAVObject @ System @@ P $ AAVEventArgs @ 4 @@ Z)< / p>

和LNK2019 未解析的外部符号“ public:class std :: basic_string,class std :: allocator> __thiscall Magick :: Image :: attribute(class std :: basic_string,class std :: allocator>)”(?attribute @ Image @ Magick @@ $$ FQAE?AV?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@ V34 @@ Z)在函数“ private:void __clrcall UseLIB :: Form1中引用: :btnStart_Click(类系统:: Object ^,类系统:: EventArgs ^)”(?btnStart_Click @ Form1 @ UseLIB @@ $$ FA $ AAMXP $ AAVObject @ System @@ P $ AAVEventArgs @ 4 @@ Z)

任何建议将不胜感激,并感谢您的期待。

1 个答案:

答案 0 :(得分:0)

原来,该问题是由于一台PC上的ImageMagick版本冲突造成的。并确保在环境变量中正确设置了MAGICK_CORE。一旦我整理出程序,就可以编译,链接和执行程序。