2

在将 ZXingWidget 包含到我以前的 iOS 项目中时,我遇到了一些问题。

这是我之前使用 XCode4.3+ARC for iOS 开始的一个项目。对于这个项目,我需要包括 ZXing 来扫描。

我遵循了提供的 README。

  1. 将 zxing 复制到项目根目录,添加 ZXingWidget.xcodeproj 项目
  2. 在构建阶段添加链接 libZXingWidget.a
  3. 将 ZXingWidget 添加到目标依赖项
  4. 标头搜索路径 - 递归 $(SRCROOT)/zxing-read-only/iphone/ZXingWidget/Classes
  5. 标头搜索路径 - 非递归 $(SRCROOT)/zxing-read-only/cpp/core/src
  6. 导入所有需要的 iOS 框架。

注意事项:

  • ZXing在iphone模拟器上编译运行正常
  • 我收到关于未定义符号的大约 66 个错误。(下面的例子)
  • Zxing 代码是从 SVN 获得的(我也试过 zip 下载,一样但是 64 错误)

但是我无法直接从我的代码中导入任何文件(#import 不起作用)。

我也没有运气尝试过这个解决方案。

我还缺少其他任何可能性吗?

任何帮助表示赞赏!

我现在得到一些错误输出。

Undefined symbols for architecture i386:
"std::ios_base::Init::Init()", referenced from:
  ___cxx_global_var_init in libZXingWidget.a(Binarizer.o)
  ___cxx_global_var_init in libZXingWidget.a(BinaryBitmap.o)
  ___cxx_global_var_init in libZXingWidget.a(Array.o)
  ___cxx_global_var_init in libZXingWidget.a(BitArray.o)
  ___cxx_global_var_init in libZXingWidget.a(BitMatrix.o)
  ___cxx_global_var_init in libZXingWidget.a(BitSource.o)
  ___cxx_global_var_init in libZXingWidget.a(Counted.o)
  ...
"std::terminate()", referenced from:
  zxing::Binarizer::Binarizer(zxing::Ref<zxing::LuminanceSource>) in libZXingWidget.a(Binarizer.o)
  zxing::Binarizer::~Binarizer() in libZXingWidget.a(Binarizer.o)
  zxing::BinaryBitmap::BinaryBitmap(zxing::Ref<zxing::Binarizer>) in libZXingWidget.a(BinaryBitmap.o)
  zxing::BinaryBitmap::~BinaryBitmap() in libZXingWidget.a(BinaryBitmap.o)
  zxing::BinaryBitmap::getBlackRow(int, zxing::Ref<zxing::BitArray>) in libZXingWidget.a(BinaryBitmap.o)
  zxing::BinaryBitmap::getWidth() const in libZXingWidget.a(BinaryBitmap.o)
  zxing::BinaryBitmap::getHeight() const in libZXingWidget.a(BinaryBitmap.o)
  ...
"operator delete(void*)", referenced from:
  zxing::Binarizer::~Binarizer() in libZXingWidget.a(Binarizer.o)
  zxing::Counted::~Counted() in libZXingWidget.a(Binarizer.o)
  zxing::BinaryBitmap::~BinaryBitmap() in libZXingWidget.a(BinaryBitmap.o)
  zxing::BinaryBitmap::crop(int, int, int, int) in libZXingWidget.a(BinaryBitmap.o)
  zxing::BinaryBitmap::rotateCounterClockwise() in libZXingWidget.a(BinaryBitmap.o)
  zxing::Counted::~Counted() in libZXingWidget.a(BinaryBitmap.o)
  zxing::BitArray::~BitArray() in libZXingWidget.a(BitArray.o)
  ...
"___cxa_allocate_exception", referenced from:
  zxing::Counted::release() in libZXingWidget.a(Binarizer.o)
  zxing::Counted::release() in libZXingWidget.a(BinaryBitmap.o)
  zxing::BitArray::setRange(int, int) in libZXingWidget.a(BitArray.o)
  zxing::BitArray::isRange(unsigned long, unsigned long, bool) in libZXingWidget.a(BitArray.o)
  zxing::BitMatrix::setRegion(unsigned long, unsigned long, unsigned long, unsigned long) in libZXingWidget.a(BitMatrix.o)
  zxing::Counted::release() in libZXingWidget.a(BitMatrix.o)
  zxing::BitSource::readBits(int) in libZXingWidget.a(BitSource.o)
  ...
4

1 回答 1

3

You need to rename main.m to main.mm. That will tell Xcode to link with the necessary C++ libraries, which is what are missing.

于 2012-07-18T23:59:23.400 回答