objective-c - 包含 Zxing 到 Xcode 4.3 + Obj-C 的 undefined symbol
<p><p>在将 ZXingWidget 包含到我之前的 iOS 项目中时,我遇到了一些问题。 </p>
<p>这是我之前使用 XCode4.3+ARC for iOS 开始的一个项目。对于这个项目,我需要包括 ZXing 来扫描。 </p>
<p>我已按照提供的自述文件进行操作。</p>
<ol>
<li>复制zxing到项目根目录,添加ZXingWidget.xcodeproj项目</li>
<li>在构建阶段添加链接 libZXingWidget.a </li>
<li>将 ZXingWidget 添加到目标依赖项</li>
<li> header 搜索路径 - 递归 $(SRCROOT)/zxing-read-only/iphone/ZXingWidget/Classes</li>
<li> header 搜索路径 - 非递归 $(SRCROOT)/zxing-read-only/cpp/core/src</li>
<li>导入所有必需的 iOS 框架。</li>
</ol>
<p>注意事项:</p>
<ul>
<li>ZXing在iphone模拟器上编译运行正常</li>
<li>我收到了大约 66 个关于 undefined symbol 的错误。 (以下示例)</li>
<li>Zxing代码是从SVN获取的(我也试过zip下载,一样但是64错误)</li>
</ul>
<p>但我无法直接从我的代码中导入任何文件
(#import 不起作用)。</p>
<p>我也试过这个<a href="https://stackoverflow.com/questions/8893983/xcode4-zxing-undefined-symbols-for-architecture-i386?rq=1" rel="noreferrer noopener nofollow">solution</a>没有运气。</p>
<p>我还缺少任何其他可能性吗?</p>
<p>感谢任何帮助!</p>
<p>我现在得到一些错误输出。</p>
<pre><code>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)
...
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>您需要将 <code>main.m</code> 重命名为 <code>main.mm</code>。这将告诉 Xcode 链接必要的 C++ 库,而这是缺少的。</p></p>
<p style="font-size: 20px;">关于objective-c - 包含 Zxing 到 Xcode 4.3 + Obj-C 的 undefined symbol ,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/11545341/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/11545341/
</a>
</p>
页:
[1]