用于libzbar.a的Xcode 5中的链接器错误 [英] Linker Error in Xcode 5 for libzbar.a

查看:95
本文介绍了用于libzbar.a的Xcode 5中的链接器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将ZBar Sdk集成到我的项目后,我的xcode 5-DP开始显示以下警告:

After I integrate ZBar Sdk into my project, my xcode 5-DP starts showing below warning:


ld:warning:links iOS模拟器的ObjC,但目标文件(/Documents/Projects/Project/Utility/ZBarSDK/libzbar.a(ZBarReaderViewController.o))是为MacOSX
编译的

"ld: warning: linking ObjC for iOS Simulator, but object file (/Documents/Projects/Project/Utility/ZBarSDK/libzbar.a(ZBarReaderViewController.o)) was compiled for MacOSX "


推荐答案

构建ZBar库

有时候我回来了与ZBar有不同的问题,并在此处引出了一组有用的指示: https://web.archive.org/web/20170128181158/http://www.federicocappelli.net/2012/10/ 05 / zbar-library-for-iphone-5-armv7s /

Sometime back I had a different problem with ZBar and was led to a helpful set of instructions here: https://web.archive.org/web/20170128181158/http://www.federicocappelli.net/2012/10/05/zbar-library-for-iphone-5-armv7s/

基本上,说明书告诉您如何使用Mercurial检查源代码,以及然后编译自己的libzbar.a文件。这应该可以解决你的问题。

Basically, the instructions tell you how to check out the source code using Mercurial, and then compile your own libzbar.a file. This ought to solve your problem.

事实上,就在昨晚,我最终不得不再次按照说明操作,因为我的ZBar版本在更新后无法运行Xcode 5.我鼓励你按照上面的链接进行操作,但是我将在这里大打折扣,以及我为新的iPhone平台添加的一些步骤。

Just last night, in fact, I ended up having to follow the instructions again, because my version of ZBar wouldn't run after updating to Xcode 5. I encourage you to follow the link above, but I'm going to largely crib it here, along with some steps I've added for the new iPhone platform.

下载并安装Mercurial for Mac。我拿了OS X 10.8的最新版本。 (安装屏幕,当你启动安装程序时,似乎仍然说10.7,所以不要感到惊讶。)

Download and install Mercurial for Mac. I took the latest one for OS X 10.8. (The installation screen, when you launch the installer, seems to still say 10.7, so don't be surprised.)

安装Mercurial后,下载ZBar的源代码以下命令:

After installing Mercurial, download the source for ZBar with the following commands:

    hg clone http://zbar.hg.sourceforge.net:8000/hgroot/zbar/zbar 
    cd zbar 
    hg checkout iPhoneSDK-1.3.1 
    open iphone/zbar.xcodeproj 

在Xcode的菜单中,选择Product> Scheme> libzbar,然后选择Product> Scheme> Edit Scheme ...。 (您将收到一条警告,告诉您项目已更新为使用LLBD调试器。是的!)

In Xcode's menu, select "Product > Scheme > libzbar" and then select "Product > Scheme > Edit Scheme…". (You'll get an alert telling you the project has been updated to use the LLBD debugger. Yay!)

在构建配置中选择运行,然后单击确定。

Select "Run" in the build configuration and click OK.

接下来,我们将为设备和模拟器编译libzbar。在Project and Targets列表中,选择libzbar目标,然后单击Build Settings选项卡。验证您的架构设置,如屏幕截图所示。 (确保它说的是iOS和arm64 armv7 armv7s。)

Next, we're going to compile libzbar for both the device and the simulator. In the Project and Targets list, select the libzbar target and click on the Build Settings tab. Verify your Architecture settings, as shown in the screenshot. (Make sure it says iOS and arm64 armv7 armv7s.)

另外,不要忘记将架构更改为标准架构(armv7,armv7s,arm64),否则您的项目将无法使用arm64进行编译。 (截图上没有正确显示)

Also, don't forget to change Architectures to Standard architectures (armv7, armv7s, arm64), otherwise your project won't compile with arm64. (This is not shown properly on screenshot)

现在,这是我昨晚发现的部分。我的部署目标设置为iOS 3.1。如果您尝试使用该设置在Xcode 5中进行编译,则会出现错误。我将其更改为iOS 7.0。

Now, here is the part I discovered last night. My Deployment Target was set to iOS 3.1. You'll get an error if you try compiling in Xcode 5 with that setting. I changed it to iOS 7.0.

验证设置并根据需要更改任何设置后,运行Build。返回产品>方案>编辑方案...并选中目的地下拉菜单。 (见上面的截图。)我在iPhone Retina(3.5英寸)上有我的。将其更改为iOS设备并再次运行Build。您现在已经构建了两次库:一次用于模拟器,一次用于设备。您需要将两个库组合在一起。转到终端中的以下目录:

After verifying your settings and changing any as needed, run Build. Go back to "Product > Scheme > Edit Scheme…" and check the "Destination" drop-down menu. (See the screenshot above.) I had mine on iPhone Retina (3.5-inch). Change it to iOS Device and run Build a second time. You have now built the library twice: once for the simulator and once for the device. You'll need to combine the two libraries. Go to the following directory in Terminal:

    cd ~/Library/Developer/Xcode/DerivedData

在一堆密码命名的目录中,其中一个将开始zbar。以下是我的完整路径,例如:

In there are a bunch of cryptically named directories, one of which will begin "zbar". Here's my full path, as an example:

    /Users/mario/Library/Developer/Xcode/DerivedData/zbar-dwpkaidpztsnjafveraeowkkjvdo

进入zbar目录,然后切换到Build / Products目录。

Go into that zbar directory, and then change into the Build/Products directory.

    cd Build
    cd Products

在那里你会看到两个文件夹:Release-iphoneos和Release-iphonesimulator。 (每个内部都是一个lizbar.a文件。)将它们与以下命令结合使用:

There you will see two folders: Release-iphoneos and Release-iphonesimulator. (Inside each is a lizbar.a file.) Combine them with the following command:

    lipo -create Release-iphoneos/libzbar.a Release-iphonesimulator/libzbar.a -o libzbar.a 

您现在已经创建了一个通用库(libzbar.a)你应该使用,替换你的ZBar发行版附带的那个。它位于相同的Build / Product目录中。

You have now created a universal library (libzbar.a) that you should use, replacing the one that came with your ZBar distribution. It is located in the same Build/Product directory.

正如我所说,我在很大程度上完成了上述链接作者Cappelli先生的指示,更新了最新的Xcode。

As I've said, I have largely cribbed the instructions from the author of the link above, Mr. Cappelli, updating them for the latest Xcode.

这篇关于用于libzbar.a的Xcode 5中的链接器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆