Question

I'm trying to make a small change to our existing iPhone app that uses ZXing to scan barcodes, and I need some help. I've been searching SO all day to try to get this resolved, with no luck.

It's been many moons (well over a year) since we last updated this app. It's an older version that we need to keep going for one customer, although for other customers I've used Xamarin to create a cross-platform app that works with Android and iOS (and WP 8, although no one is using that one yet). So the single Mac we have that was used by a former employee to create the app and now we just use to compile our Xamarin version has been updated to use XCode 4.6.2.

When I made a change to the code and tried to rebuild, I got several errors which I fixed after finding help here on SO. Now I'm getting some errors that no answers on SO have been able to resolve.

Here are the errors I'm getting:

Undefined symbols for architecture armv7:
  "zxing::common::StringUtils::SHIFT_JIS", referenced from:
      zxing::qrcode::DecodedBitStreamParser::decodeKanjiSegment(zxing::Ref<zxing::BitSource>, std::string&, int) in libZXingWidget.a(DecodedBitStreamParser-64E27B33E79CBC52.o)
  "zxing::common::StringUtils::GB2312", referenced from:
      zxing::qrcode::DecodedBitStreamParser::decodeHanziSegment(zxing::Ref<zxing::BitSource>, std::string&, int) in libZXingWidget.a(DecodedBitStreamParser-64E27B33E79CBC52.o)
  "zxing::common::StringUtils::ASCII", referenced from:
      zxing::qrcode::DecodedBitStreamParser::decodeNumericSegment(zxing::Ref<zxing::BitSource>, std::string&, int) in libZXingWidget.a(DecodedBitStreamParser-64E27B33E79CBC52.o)
      zxing::qrcode::DecodedBitStreamParser::decodeAlphanumericSegment(zxing::Ref<zxing::BitSource>, std::string&, int, bool) in libZXingWidget.a(DecodedBitStreamParser-64E27B33E79CBC52.o)
  "zxing::WhiteRectangleDetector::detect()", referenced from:
      zxing::datamatrix::Detector::detect() in libZXingWidget.a(Detector-9FC86B67C0CBCF52.o)
  "zxing::common::StringUtils::UTF8", referenced from:
      zxing::qrcode::DecodedBitStreamParser::append(std::string&, unsigned char const*, unsigned long, char const*) in libZXingWidget.a(DecodedBitStreamParser-64E27B33E79CBC52.o)
  "zxing::common::StringUtils::guessEncoding(unsigned char*, int, std::map<unsigned int, std::string, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, std::string> > > const&)", referenced from:
      zxing::qrcode::DecodedBitStreamParser::decodeByteSegment(zxing::Ref<zxing::BitSource>, std::string&, int, zxing::common::CharacterSetECI*, zxing::ArrayRef<zxing::ArrayRef<unsigned char> >&, std::map<unsigned int, std::string, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, std::string> > > const&) in libZXingWidget.a(DecodedBitStreamParser-64E27B33E79CBC52.o)

As you can see, the errors are all in the zxing namespace. I can load the ZXingWidget project and build it with no errors, but my project which includes it won't link to the zxing core stuff. I've tried switching the C++ compiler, standard library, language dialect, etc.

At this point I'll take either of two solutions:

  1. Fix my project so it builds
  2. Remove the ZXingWidget project from my project and somehow just pull in the binary as a dependency. I'm not an Objective-C or XCode developer, so I don't know how to do that. In the Visual Studio world instead of having the ZXingWidget project in my solution and including a project reference I'd just put the DLL in a folder in my solution and include it as a regular DLL reference.
Was it helpful?

Solution

I was able to fix my build. The ZXingWidget project refers to files in the cpp folder which resides in a folder at the same level as my main project. This is how the ZXing documentation says to do it (and it was working before I upgraded XCode) even though it doesn't make total sense to me. So the folders look like this:

  • Base folder
    • cpp
    • My project
      • ZXingWidget

The instructions for including ZXingWidget in your project tell you to add ../../cpp/core/src to your searched headers. The files the linker was complaining about are all in there, so I manually added each one the linker complained about to the Compile Sources in the ZXingWidget project's target.

After that I only had one linker error, which I fixed by changing the Deployment Target on my main project and it's target from 3.0 to 5.1.1 (I would have set it to 4.3, but it said the armv64 architecture had a minimum of 5.1.1 - don't know if I need that architecture, but whatever).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top