xcode 4.5 和 ios 6 中的 zxing

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12665457/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 15:50:32  来源:igfitidea点击:

zxing in xcode 4.5 and ios 6

iosxcodezxing

提问by Alan Harper

As many of you noticed; zxing does not work in latest xcode (4.5/ios 6)

正如你们许多人注意到的那样;zxing 在最新的 xcode (4.5/ios 6) 中不起作用

Here is use case:

这是用例:

  1. checkout latest version from trunk (as some fixes were already added)
  2. create single view application in xcode 4.5 with ios 6.0
  3. use README to add dependencies, paths etc (just follow step by step)
  4. add zxingcontroller call to class (renamed to mm)
  1. 从主干结帐最新版本(因为已经添加了一些修复程序)
  2. 使用 ios 6.0 在 xcode 4.5 中创建单视图应用程序
  3. 使用 README 添加依赖项、路径等(只需一步一步)
  4. 将 zxingcontroller 调用添加到类(重命名为 mm)

Compilation fails both for simulator and device It shows 31 error like this one:

模拟器和设备的编译都失败 它显示 31 错误,如下所示:

Undefined symbols for architecture i386:
  "std::string::c_str() const", referenced from

all 31 errors are similar, difference is in symbols name

所有 31 个错误都相似,区别在于符号名称

May be somebody knows how to solve it with this use case?

可能有人知道如何用这个用例解决它?

p.s. if you have app from previous Xcode, it works. Problem is only if you create new app in Xcode 4.5

ps 如果你有以前 Xcode 的应用程序,它就可以工作。问题仅在于您在 Xcode 4.5 中创建新应用程序

回答by Till

The issue you have encountered seems to be C++ standard library related.

您遇到的问题似乎与 C++ 标准库有关。

Actually, whenever you see linker failures in relationship with standard library objects (e.g. std::string), you should check the project settings on all linked libraries and the app-project itself. They usually need to match!

实际上,每当您看到与标准库对象(例如std::string)相关的链接器失败时,您应该检查所有链接库和应用程序项目本身的项目设置。他们通常需要匹配!

The original ScanTest (which builds ZXingWidget as a subproject) uses the following settings and those need to match your App build-settings if you use the library as is.

原始 ScanTest(将 ZXingWidget 作为子项目构建)使用以下设置,如果您按原样使用库,则需要匹配您的应用程序构建设置。

For making sure, I created a brand-new project using Xcode 4.5. That project uses ZXingWidget as a prebuilt library but not as a subproject - I dont like subprojects for stuff that is not my own - though this specialty wont influence the results.

为了确保,我使用 Xcode 4.5 创建了一个全新的项目。该项目使用 ZXingWidget 作为预建库而不是子项目——我不喜欢子项目不是我自己的——尽管这个专业不会影响结果。

The important setting is C++ Standard Library- make sure that is set towards Compiler Default

重要的设置是C++ 标准库- 确保设置为编译器默认值

enter image description here

在此处输入图片说明



Little clarification

小澄清

Actually, you do not need to use C++ Standard Library, you may as well use LLVM C++ standard library with C++11 support. Butyou will have to use that exact same library in all projects, sub-projects and libraries that link with your project. So if you insist on using the more recent version of that library (C++11 support), then you will have to build the ZXing library with those settings as well.

实际上,您不需要使用C++ 标准库,您也可以使用支持 C++11 的 LLVM C++ 标准库但是您必须在与您的项目链接的所有项目、子项目和库中使用完全相同的库。因此,如果您坚持使用该库的更新版本(C++11 支持),那么您还必须使用这些设置构建 ZXing 库。



Last but not least, make sure your Architecturesand Valid Architecturesettings are matching over all projects and sub projects (fixing the common armv7slinker issue).

最后但并非最不重要的一点是,确保您的架构有效架构设置在所有项目和子项目中匹配(修复常见的armv7s链接器问题)。

First, make sure your Architecturessetting is set towards armv7armv7swithin all projects. Then also edit the project settings of all projects towards Valid Architecturearmv7sarmv7.

首先,确保您的架构设置armv7armv7s在所有项目中都设置为朝向。然后还将所有项目的项目设置编辑为Valid Architecturearmv7sarmv7

enter image description here

在此处输入图片说明

回答by Gerd

You might also want to switch the "Other Warning Flag" -Werror off. Seems to be necessary in Xcode versions > 4.5 (LLVM compiler > 4.1).

您可能还想关闭“其他警告标志”-Werror。在 Xcode 版本 > 4.5(LLVM 编译器 > 4.1)中似乎是必要的。

回答by banDedo

It works for me, have you enabled -lstdc++ in your list of Other Linker Flags in the Build Settings tab of the project target? It sounds like it is not recognizing the c++ symbols needed for zXing to build. If this is the case, the above advice should help.

它对我有用,您是否在项目目标的“构建设置”选项卡中的“其他链接器标志”列表中启用了 -lstdc++?听起来它无法识别 zXing 构建所需的 C++ 符号。如果是这种情况,上述建议应该会有所帮助。