3

I'm trying to work with ZXing and OpenCV in the same project. You wouldn't think this would be this rare of thing to do, but I guess it is. I am having some serious compatibility issues between the two. I can only get one imported without the other.

I start with OpenCV and everything works fine. Program runs as expected. Then I add ZXing, and I get about 27 compiler errors. There is a stackoverflow question that address this here. So I change my C++ compiler settings to match what this question suggests, and it fixes the ZXing problems, but then opens up a whole new set of errors. These errors are related to OpenCV now(see below).

EDIT:
It seems that depending on the C++ compiler, its a one-or-the-other type deal. In fact, if you change the c++ standard library from libc++ to libstdc++ you will get one to work and not the other. No way I can see to get both at the same time enter image description here

Community
  • 1
  • 1
Jameo
  • 4,507
  • 8
  • 40
  • 66

2 Answers2

5

I have found a solution to my question. This applies best to anyone using zxing and opencv in the same project.

  1. Go to the project settings -> Target -> search for c++ a. Switch c++ Language Dialect to Compiler Default b. Switch C++ Standard Library to libc++
  2. Go to the ZXingWidget.xcodeproj -> ZXingWidget -> search for C++ a. Switch c++ Language Dialect to Compiler Default b. Switch C++ Standard Library to libc++
  3. There will be a compiler error saying that ZXing can't compile to libc++ because it's currently set to support iOS 4.3. Go into ZXing widget again, and change the deployment target to be 5.0 (sorry all of you trying to still support < 5)

This fixed my problem. Basically what was happening is that zxing and open cv were compiling on different versions of c++, which was causing some strange issues

Edit: For reference, I was using ZXing 2.1 and OpenCV 2.4.3 (Newest versions at the time of the question)

Jameo
  • 4,507
  • 8
  • 40
  • 66
0

Actually, I use your solution but a little different. At step2,I change both to Complier Default, because if I use your suggestion,the error still there.So I checked the setting in ZXingWidget.xcodeproj and found that it set both Complier Default, so I changed my project setting the same as ZXingWidget.xcodeproj. But thanks to your hint and helped me a lot!

  • At the time I did it, my solution worked without any errors. I think both of these libraries have been updated though, so that might be true – Jameo Jun 28 '13 at 13:50