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

这是我较早使用iOS的XCode4.3 + ARC开始的项目。对于此项目,我需要包括ZXing进行扫描。

我遵循了提供的自述文件。

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

  • 注意事项:
  • ZXing已在iPhone模拟器
  • 上编译并正常运行
  • 我收到有关未定义符号的约66个错误。 (下面的示例)
  • Zxing代码是从SVN获得的(我也尝试过zip下载,相同但有64个错误)

  • 但是我无法直接从我的代码中导入任何文件
    (#import无法正常工作)。

    我也没有运气尝试过这个solution

    我还缺少其他可能性吗?

    任何帮助表示赞赏!

    我现在得到一些错误输出。
    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)
      ...
    

    最佳答案

    您需要将main.m重命名为main.mm。这将告诉Xcode链接到必需的C++库,而缺少这些库。

    关于objective-c - 包含Zxing到Xcode 4.3 + Obj-C时的 undefined symbol ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11545341/

    10-10 20:49