在編譯zxing cpp的時候報錯:
錯誤 14 error LNK2005: public: static unsigned int const zxing::DecodeHints::CHARACTER_SET (?CHARACTER_SET@DecodeHints@zxing@@2IB) 已經在 AztecReader.obj 中定義 DecodeHints.obj?
解決方法如下:
1、將decodeHints.cpp中的const DecodeHintType DecodeHints::CHARACTER_SET;改為const DecodeHintType DecodeHints::CHARACTER_SET = 1 << 30;
2、將decodeHints.h中的static const DecodeHintType CHARACTER_SET = 1 << 30;改為? static const DecodeHintType CHARACTER_SET;
錯誤14 error LNK2005: "private: static int const zxing::pdf417::detector::LinesSampler::BARCODE_START_OFFSET" (?BARCODE_START_OFFSET@LinesSampler@detector@pdf417@zxing@@0HB) 已經在 LinesSampler.obj 我還報了幾個錯誤除了BARCODE_START_OFFSET還有MODULES_IN_SYMBOL、BBARS_IN_SYMBOL、POSSIBLE_SYMBOLS,所以我修改如下(你可以根據自己的錯誤自行修改):
1、將LinesSampler.cpp中的const int LinesSampler::MODULES_IN_SYMBOL;改為const int LinesSampler::MODULES_IN_SYMBOL = 17;
const int LinesSampler::BARS_IN_SYMBOL;改為const int LinesSampler::BARS_IN_SYMBOL = 8;
const int LinesSampler::POSSIBLE_SYMBOLS;改為const int LinesSampler::POSSIBLE_SYMBOLS = 2787;
const int LinesSampler::BARCODE_START_OFFSET;改為const int LinesSampler::BARCODE_START_OFFSET = 2;
2、
將LinesSampler.h中的static const int MODULES_IN_SYMBOL = 17;改為static const int MODULES_IN_SYMBOL;
將static const int BARS_IN_SYMBOL = 8;改為static const int BARS_IN_SYMBOL;
將static const int POSSIBLE_SYMBOLS = 2787;改為static const int POSSIBLE_SYMBOLS;
將static const int BARCODE_START_OFFSET = 2;改為static const int BARCODE_START_OFFSET;
解決上面的錯誤之后還報:錯誤14 error LNK2019: 無法解析的外部符號 _main,該符號在函數 ___tmainCRTStartup 中被引用
報這個錯誤很簡單處理,原因是因為沒有main函數作為入口導致的,你自己新建一個cpp文件然后寫一個main函數。