为什么向xcode 7.2示例项目添加静态libcurl.a将添加libcurl.4.dylib依赖项 [英] Why adding static libcurl.a to xcode 7.2 example project will add a libcurl.4.dylib dependency

查看:2700
本文介绍了为什么向xcode 7.2示例项目添加静态libcurl.a将添加libcurl.4.dylib依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试图通过将libcurl.a添加到我的Xcode 7.2项目来消除对libcurl.4.dylib的任何依赖。我已经构建了一个全新的libcurl,并将它放置在/ usr / local / lib(头/ in / usr / local / include / curl):

  export MACOSX_DEPLOYMENT_TARGET =10.8
./configure --disable-shared --with-darwinssl
make clean
make
make install

但是.app是STILL与libcurl.4.dylib的依赖关系。



虽然我将libcurl.a添加到我的XcodeLink Binary with Libraries构建阶段,但是Xcode的-lcurl的生成的链接命令是告诉链接器默认为
,链接到DYNAMIC库。链接器不会接受
-static作为-l的前缀,因为CLANG驱动程序不支持
在每个文件的基础上打开/关闭-static / -dynamic(如果链接器



一旦我改变了(在MANUAL shell链接行中)Xcode生成的-lcurl显式地/usr/local/lib/libcurl.a,链接的.app不再显示对libcurl.4.dylib的依赖。



它似乎没有简单的方法来通过
Xcode来做到这一点 - 除非我用不同的名称复制libcurl.a。



也许其他人知道magicparams / build选项为Xcode 7.2,或有更多的洞察力,但我想离开这里,以防任何人遇到这个问题与libcurl - 或任何其他静态(.a)库,其中碰巧是一个



编辑:这是在同一位置使用相同名称的动态(.dylib)。



命令行我用来构建通用静态库:

  export MACOSX_DEPLOYMENT_TARGET =10.10
./ configure --prefix = $ HOME CFLAGS = - arch i386 x86_64LDFLAGS = - arch i386 x86_64--disable-shared --with-darwinssl --without-zlib --without- libidn --disable-ldap
make clean
make
sudo make install


解决方案

我试过SMGreenfield建议的方法,它没有为我工作。原因之一:该库不能在通用环境中使用,因为文件 curlbuild.h 对于每个体系结构都不同。将此作为来源


I had been trying to eliminate any dependency on libcurl.4.dylib by adding libcurl.a to my Xcode 7.2 project. I had built a brand-new libcurl and placed it in /usr/local/lib (with the header in /usr/local/include/curl):

export MACOSX_DEPLOYMENT_TARGET="10.8"
./configure --disable-shared --with-darwinssl
make clean
make
make install

But the .app was STILL linked with a dependency on libcurl.4.dylib. Finding out why took several days.

Although I am adding libcurl.a to my Xcode "Link Binary with Libraries" Build Phase, Xcode's generated link command of -lcurl is telling the linker to, by default, link with a DYNAMIC library. The linker will NOT accept -static as a prefix to -l, because the CLANG driver doesn't support turning on/off -static/-dynamic on a per-file basis (if the linker does see -static, it expects that EVERYTHING is static — which Apple STRONGLY DISCOURAGES).

Once I changed (in a MANUAL shell link line) the Xcode-generated -lcurl to be explicitly "/usr/local/lib/libcurl.a", the linked .app no longer showed a dependency on libcurl.4.dylib.

What sucks is that it appears there is no easy method to do this through Xcode — unless I make a copy of libcurl.a with a DIFFERENT NAME.

Maybe others know the "magic" params / build options for Xcode 7.2, or have more insight, but I wanted to leave this here in case anyone else ran into this issue with libcurl -- or any other static (.a) library where there happened to be a dynamic (.dylib) of the same name in the same location.

Stephen

EDIT: This is the command line(s) I used to build the universal static library:

export MACOSX_DEPLOYMENT_TARGET="10.10"
./configure --prefix=$HOME CFLAGS="-arch i386 x86_64" LDFLAGS="-arch i386 x86_64" --disable-shared --with-darwinssl --without-zlib  --without-libidn --disable-ldap
make clean
make
sudo make install

解决方案

I tried the approach suggested by SMGreenfield and it did not work for me. One of the reasons: the library cannot be used in the universal environment because file curlbuild.h is different for each architecture. Using this as a source https://curl.haxx.se/mail/lib-2015-08/0146.html, I did the following. Have not been able to do a lot of testing yet, but the library compiled without error "curl_rule_01 declared as an array with negative size".

  1. Build 64-bit static libcurl:

Download CURL source file to: /Users/yourname/Libs/.

Create folder /Users/yourname/Libs/curl_64.

Type in Terminal:

$ cd /Users/yourname/Libs/curl-7.52.1
$ export MACOSX_DEPLOYMENT_TARGET="10.7"
$ export CFLAGS="-arch x86_64"
$ export LDFLAGS="-arch x86_64"
$ ./configure --prefix=/Users/yourname/Libs/curl_64 --disable-shared -–enable-static --without-libidn –-without-zlib -–disable-ldap
$ make clean
$ make
$ make install

  1. Build 32-bit static libcurl:

Create folder /Users/yourname/Libs/curl_32.

Type in Terminal:

$ cd /Users/yourname/Libs/curl-7.52.1
$ export MACOSX_DEPLOYMENT_TARGET="10.7"
$ export CFLAGS="-arch i386"
$ export LDFLAGS="-arch i386"
$ ./configure --prefix=/Users/yourname/Libs/curl_32 --disable-shared –-enable-static --without-libidn –-without-zlib -–disable-ldap
$ make clean
$ make
$ make install

  1. Create universal libcurl:

Create folder /Users/yourname/Libs/curl_universal/lib.

Lipo two static libraries:

lipo -create /Users/yourname/Libs/curl_32/lib/libcurl.a /Users/yourname/Libs/curl_64/lib/libcurl.a –output /Users/yourname/Libs/curl_universal/libcurl.a

Copy all subfolders from /Users/yourname/Libs/curl_64 to /Users/yourname/Libs/curl_universal except for subfolder lib!

In folder /Users/yourname/Libs/curl_universal/include/curl copy file curlbuild.h and save as curlbuild64.h. Copy this file from folder /Users/yourname/Libs/curl_32/include/curl to folder /Users/yourname/Libs/curl_universal/include/curl and save it as curlbuild32.h. Now we should have three files: curlbuild.h, curlbuild64.h, and curlbuild32.h.

  1. Open file curlbuild.h and edit as follows:

这篇关于为什么向xcode 7.2示例项目添加静态libcurl.a将添加libcurl.4.dylib依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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