简体   繁体   English

在OS X Yosemite,xCode 6上构建libxml2-2.9.2

[英]Building libxml2-2.9.2 on OS X Yosemite, xCode 6

I have an xcode project which uses xmppframework . 我有一个使用xmppframework的xcode项目。

the KissXML module of this framework needs libxml2, according to https://github.com/robbiehanson/KissXML/wiki/GettingStarted . 根据https://github.com/robbiehanson/KissXML/wiki/GettingStarted所述,此框架的KissXML模块需要libxml2。

I followed these instructions, and downloaded libxml2 from ftp://xmlsoft.org/libxml2/ . 我遵循了这些说明,并从ftp://xmlsoft.org/libxml2/下载了libxml2。 Specifically, I downloaded and extracted LATEST_LIBXML2, which turns out to be libxml2-2.9.2. 具体来说,我下载并提取了LATEST_LIBXML2,结果为libxml2-2.9.2.。

I then added the relevant header search path to my xcode project, and 然后,将相关的标题搜索路径添加到我的xcode项目中,然后

-l "lxml2" -l“ lxml2”

to my linker flags. 我的链接器标志。

However, when I build my project, it gives the following linker error: 但是,当我构建项目时,它会出现以下链接器错误:

ld: library not found for -llxml2 clang: error: linker command failed with exit code 1 (use -v to see invocation) ld:找不到用于-llxml2 clang的库:错误:链接器命令失败,退出代码为1(使用-v查看调用)

I suspect this is because I need to build libxml2 myself, in order to get the library binary. 我怀疑这是因为我需要自己构建libxml2才能获取库二进制文件。 However, I can't find specific instructions for doing this on OS X Yosemite, xcode 6. 但是,我找不到在OS X Yosemite,xcode 6上执行此操作的具体说明。

Does anyone have any instructions on building libxml2-2.9.2 on OS X Yosemite, Xcode 6, so that I can link to it in my project? 是否有人在OS X Yosemite,Xcode 6上构建libxml2-2.9.2有任何说明,以便可以在项目中链接到它?

Alternatively, if someone can provide a binary for libxml2-2.9.2, that might also work. 或者,如果有人可以为libxml2-2.9.2提供二进制文件,那也可能会起作用。 I did find http://www.explain.com.au/oss/libxml2xslt.html#id2658905 , but this guy only seems to offer binaries for older versions of libxml2, not the current version. 我确实找到了http://www.explain.com.au/oss/libxml2xslt.html#id2658905 ,但是这个家伙似乎只提供libxml2的较旧版本的二进制文件,而不是当前版本的二进制文件。 Thanks! 谢谢!

Best regards, 最好的祝福,

Chris 克里斯

I have built LibXML2 (latest version 2.9.2) on Solaris SPARC, Linux and Windows. 我已经在Solaris SPARC,Linux和Windows上构建了LibXML2 (最新版本2.9.2)。 I have never use MacOS (poor =)) ). 我从未使用过MacOS(poor =)))。

Here's my brief instruction . 这是我的简短指示 You can try the similar way. 您可以尝试类似的方法。

cd /opt/mydir/libxml2
mkdir linux-gcc3
gunzib -c libxml2-2.9.2.tar.gz | tar xvf –
cd libxml2-2.9.2
./configure --prefix=/opt/mydir/libxml2/linux-gcc3 --enable-static --disable-shared 2>&1 | tee conf.log
 ## 64 bit
 ## ./configure CC="cc -m64" --prefix=/opt/mydir/libxml2/linux-gcc3 --enable-static --disable-shared 2>&1 | tee conf.log
 make 2>&1 | tee make.log
 make install

Well firstly, the library is called libxml2, so the link should be -lxml2 and not -llxml2 . 首先,该库名为libxml2,因此链接应为-lxml2而不是-llxml2

Secondly, there is already a libxml2 built-in to OSX/iOS, and you can actually reference that library in the link libraries section for the project. 其次,OSX / iOS已经内置了libxml2,您实际上可以在项目的链接库部分中引用该库。 You generally don't need to build the library unless you really want newer features of the newer version. 通常,除非确实需要更新版本的更新功能,否则通常不需要构建库。

In the General tab of the project, use the Linked frameworks and Libraries to add a reference to libxml2.dylib . 在项目的“常规”选项卡中,使用“ Linked frameworks and Libraries添加对libxml2.dylib的引用。

The instructions on the page you reference are using the version of libxml2 that is available on OSX/iOS already. 您所引用页面上的说明正在使用OSX / iOS上已经可用的libxml2版本。 You do not need to download libxml2 to get it to work. 您无需下载libxml2即可使其工作。

The location that's mentioned /usr/include/libxml2 on the page will work for you also if you install the command line developer tools - at a terminal prompt do xcode-select --install . 如果您安装命令行开发人员工具,那么在页面上/usr/include/libxml2提到的位置也将为您工作-在终端提示符下,执行xcode-select --install

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM