使用自定义OpenSSL目录编译libcurl

时间:2018-05-15 16:00:04

标签: openssl cross-compiling libcurl

我已将OpenSSL构建到自定义构建目录中:

/Users/builder/dev/artifact_staging/temp/openssl

现在,当我配置libcurl时,我指出它在该目录中使用OpenSSL:

./configure
  --without-zlib \
  --enable-static \
  --enable-ipv6 \
  --with-ssl=/Users/builder/dev/artifact_staging/temp/openssl \
  --host="arm-apple-darwin" \
  --prefix=/Users/builder/dev/artifact_staging/temp/libcurl

问题是我在配置结束时得到的摘要报告告诉我它不会使用SSL:

curl version:     7.59.0
  Host setup:       x86_64-apple-darwin17.5.0
  Install prefix:   /usr/local
  Compiler:         gcc
  SSL support:      no      (--with-{ssl,gnutls,nss,polarssl,mbedtls,cyassl,axtls,winssl,darwinssl} )
  SSH support:      no      (--with-libssh2)
  zlib support:     enabled
  brotli support:   no      (--with-brotli)
  GSS-API support:  no      (--with-gssapi)
  TLS-SRP support:  no      (--enable-tls-srp)
  resolver:         POSIX threaded
  IPv6 support:     enabled
  Unix sockets support: enabled
  IDN support:      enabled (libidn2)
  Build libcurl:    Shared=yes, Static=yes
  Built-in manual:  enabled
  --libcurl option: enabled (--disable-libcurl-option)
  Verbose errors:   enabled (--disable-verbose)
  SSPI support:     no      (--enable-sspi)
  ca cert bundle:   /etc/ssl/cert.pem
  ca cert path:     no
  ca fallback:      no
  LDAP support:     enabled (OpenLDAP)
  LDAPS support:    enabled
  RTSP support:     enabled
  RTMP support:     no      (--with-librtmp)
  metalink support: no      (--with-libmetalink)
  PSL support:      no      (libpsl not found)
  HTTP2 support:    disabled (--with-nghttp2)
  Protocols:        DICT FILE FTP GOPHER HTTP IMAP LDAP LDAPS POP3 RTSP SMTP TELNET TFTP

我的配置调用中缺少什么?

更新1

我的config.log文件中发现了一些错误

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/netdb.h:277:17: note: previous declaration is here
int             getnameinfo(const struct sockaddr * __restrict, socklen_t,
                ^
1 error generated.


gcc -o conftest -Qunused-arguments -Os -mmacosx-version-min=10.8 -Werror=partial-availability  -I/usr/local/Cellar/libidn2/2.0.4/include  -L/usr/local/Cellar/libidn2/2.0.4/lib conftest.c -lidn2 -lldap >&5
conftest.c:307:3: error: expected identifier or '('
} # AC-LANG-PROGRAM
  ^
1 error generated.


fatal error: 'ac_nonexistent.h' file not found
#include <ac_nonexistent.h>
         ^~~~~~~~~~~~~~~~~~
1 error generated.


error: use of undeclared identifier 'force'
      force compilation error
      ^
1 error generated.


error: 'bad_t' declared as an array with a negative size
      typedef char bad_t[sizeof(char) == sizeof(int) ? -1 : -1 ];
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

更新2

经过更多阅读后,我做了以下修改。它仍然没有给我我想要的东西,但我想知道我是否走在正确的轨道上。

我已经使用我认为正确的主机修改了我的配置参数:

./configure
  --without-zlib \
  --enable-static \
  --enable-ipv6 \
  --with-ssl=/Users/builder/dev/artifact_staging/temp/openssl \
  --host="arm64-apple-darwin" \
  --prefix=/Users/builder/dev/artifact_staging/temp/libcurl

我还添加了几个标志:

export CPPFLAGS="-arch=arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -I/Users/builder/dev/artifact_staging/temp/openssl/include"

export LDFLAGS="-arch=arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -L/Users/builder/dev/artifact_staging/temp/openssl/lib"

现在当我运行configure时,我最终仍然没有得到ssl支持,当我检查config.log文件时,我看到了

clang: warning: using sysroot for 'iPhoneOS' but targeting 'MacOSX' [-Wincompatible-sysroot]

我不确定我在这里缺少什么让它认为我的目标是MacOSX;到目前为止,我所做的每件事都指定了arm64。

还有其他实际错误,但我认为它们是因为它认为我正在尝试构建x86_64而不是arm64。

ld: dynamic main executables must link with libSystem.dylib for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
configure:4386: $? = 1
configure:4424: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "curl"
| #define PACKAGE_TARNAME "curl"
| #define PACKAGE_VERSION "-"
| #define PACKAGE_STRING "curl -"
| #define PACKAGE_BUGREPORT "a suitable curl mailing list: https://curl.haxx.se/mail/"
| #define PACKAGE_URL ""
| /* end confdefs.h.  */
| 
| int main (void)
| {
| 
|  ;
|  return 0;
| }
configure:4429: error: in `/Users/builder/dev/artifact_staging/curl-7.59.0':
configure:4431: error: C compiler cannot create executables

我错过了我的旗帜中的参数吗?

0 个答案:

没有答案