用的代码是这些
#include <iostream>
#include <Magick++.h>
#include <zbar.h>
#pragma comment(lib,"CORE_RL_Magick++_.lib")
#define STR(s) #s
using namespace std;
using namespace zbar;
int main(int argc, char **argv)
{
// if(argc < 2) return(1);
#ifdef MAGICK_HOME
// http://www.imagemagick.org/Magick++/
// under Windows it is necessary to initialize the ImageMagick
// library prior to using the Magick++ library
Magick::InitializeMagick(MAGICK_HOME);
#endif
// create a reader
ImageScanner scanner;
// configure the reader
scanner.set_config(ZBAR_NONE, ZBAR_CFG_ENABLE, 1);
// obtain image data
Magick::Image magick("barcode.png"); // read an image file
int width = magick.columns(); // extract dimensions
int height = magick.rows();
Magick::Blob blob; // extract the raw data
magick.modifyImage();
magick.write(&blob, "GRAY", 8);
const void *raw = blob.data();
// wrap image data
Image image(width, height, "Y800", raw, width * height);
// scan the image for barcodes
int n = scanner.scan(image);
// extract results
for (Image::SymbolIterator symbol = image.symbol_begin();
symbol != image.symbol_end();
++symbol) {
// do something useful with results
cout << "decoded " << symbol->get_type_name()
<< " symbol \"" << symbol->get_data() << '"' << endl;
}
// clean up
image.set_data(NULL, 0);
return(0);
}
报错是如下
1>------ 已启动生成: 项目: ConsoleApplication5, 配置: Debug Win32 ------
1> 源.cpp
1>源.obj : error LNK2019: 无法解析的外部符号 "public: __thiscall Magick::Blob::Blob(void)" (??0Blob@Magick@@QAE@XZ),该符号在函数 _main 中被引用
1>源.obj : error LNK2019: 无法解析的外部符号 "public: virtual __thiscall Magick::Blob::~Blob(void)" (??1Blob@Magick@@UAE@XZ),该符号在函数 _main 中被引用
1>源.obj : error LNK2019: 无法解析的外部符号 "public: void const * __thiscall Magick::Blob::data(void)const " (?data@Blob@Magick@@QBEPBXXZ),该符号在函数 _main 中被引用
1>源.obj : error LNK2019: 无法解析的外部符号 "public: __thiscall Magick::Image::Image(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0Image@Magick@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z),该符号在函数 _main 中被引用
1>源.obj : error LNK2019: 无法解析的外部符号 "public: virtual __thiscall Magick::Image::~Image(void)" (??1Image@Magick@@UAE@XZ),该符号在函数 _main 中被引用
1>源.obj : error LNK2019: 无法解析的外部符号 "public: unsigned int __thiscall Magick::Image::columns(void)const " (?columns@Image@Magick@@QBEIXZ),该符号在函数 _main 中被引用
1>源.obj : error LNK2019: 无法解析的外部符号 "public: unsigned int __thiscall Magick::Image::rows(void)const " (?rows@Image@Magick@@QBEIXZ),该符号在函数 _main 中被引用
1>源.obj : error LNK2019: 无法解析的外部符号 "public: void __thiscall Magick::Image::write(class Magick::Blob *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned int)" (?write@Image@Magick@@QAEXPAVBlob@2@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@I@Z),该符号在函数 _main 中被引用
1>源.obj : error LNK2019: 无法解析的外部符号 "public: void __thiscall Magick::Image::modifyImage(void)" (?modifyImage@Image@Magick@@QAEXXZ),该符号在函数 _main 中被引用
1>LIBCMTD.lib(wwincrt0.obj) : error LNK2019: 无法解析的外部符号 _wWinMain@16,该符号在函数 ___tmainCRTStartup 中被引用
1>D:\我的文档\Visual Studio 2013\Projects\ConsoleApplication5\Debug\ConsoleApplication5.exe : fatal error LNK1120: 10 个无法解析的外部命令
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========