2

I am facing some problem while including ZXingWidget to my previous iOS project.

It is a project which I started earlier using XCode4.3+ARC for iOS. For this project I need to include ZXing to scan.

I had followed the README provided.

  1. Copy zxing into project root, add ZXingWidget.xcodeproj project
  2. Adding link libZXingWidget.a in build phases
  3. Added ZXingWidget to target dependencies
  4. Header Search Paths - recursive $(SRCROOT)/zxing-read-only/iphone/ZXingWidget/Classes
  5. Header Search Paths - non-recursive $(SRCROOT)/zxing-read-only/cpp/core/src
  6. Import all the required iOS frameworks.

Things to note:

  • ZXing compiled and run properly on iphone simulator
  • I am getting about 66 errors about undefined symbols. (example below)
  • Zxing code is obtained from SVN (I also tried the zip download, same but 64 errors)

But I could not import any file directly from my code (#import not working).

I also tried this solution with no luck.

Any other possibilities that I am missing?

Any help is appreciated!

Some error output I am getting now.

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)
  ...
Community
  • 1
  • 1
Orange
  • 185
  • 1
  • 13
  • the libZXingWidget.a in my "Link Binary With Binaries" is red in color. What does this mean? – Orange Jul 18 '12 at 16:00
  • I don't pay attention to the color. I think it's supposed to represent whether the indicated file exists but with linked projects, it seems inconsistent and not to matter. – smparkes Jul 19 '12 at 00:00
  • @Orange that it was not found or it is not properly linked. – Pochi Jul 19 '12 at 00:05
  • yea I could finally run the ZxingWidgetController in my app. Everything seems good atm. But the field in "Link Binary with Binaries" for libZXingWidget is still red. And my other TapkuLibrary was red, but now it is black. – Orange Jul 19 '12 at 01:09

1 Answers1

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.

smparkes
  • 13,807
  • 4
  • 36
  • 61
  • thanks! it works now. But I found compiler error at my other pure obj-c file which uses "namespace" as variable (which is a keyword in C++). Is this normal, or I just edited something wrong. – Orange Jul 19 '12 at 01:06
  • You can't use namespace as a symbol name (variable or type) in anything C++ related: either a `.mm` file or in a `.h` file included in a `.mm` file (directly or not). I'd strongly recommend not using any C++ reserved words (namespace, template, etc.) in your Objective C. – smparkes Jul 19 '12 at 01:46