【问题标题】:Building Cross-Compiler: Intel Xeon E5649 >>> ARMv7 with libcURL构建交叉编译器:Intel Xeon E5649 >>> ARMv7 with libcURL
【发布时间】:2015-12-21 08:42:23
【问题描述】:

我并不完全理解 libcURL 的手册/帮助。我正在尝试构建一个包含 libcURL 库的交叉编译器。我在这个video 的帮助下在我的服务器上安装了一个交叉编译器,并且可以用arm-linux-gnueabihf-gcc hello_simple.c 启动它。我可以编译像printf ("Hello World"); 这样的简单c 代码之后我尝试安装libcURL 并阅读我需要编译lib 并使用configure 文件来设置构建和主机。我使用了不同的配置,例如:sudo ./configure --build=i586-pc-linux-gnu --host=arm-linux --target=arm-linux --prefix=/home/nevadmin/dev/gcc,但都没有工作。我想我在某个地方犯了错误。这是配置完成后的输出:

curl version:     7.46.0
Host setup:       arm-unknown-linux-gnu
Install prefix:   /home/nevadmin/dev/gcc
Compiler:         gcc
SSL support:      no      (--with-{ssl,gnutls,nss,polarssl,mbedtls,cyassl,axtls,winssl,darwinssl} )
SSH support:      no      (--with-libssh2)
zlib support:     no      (--with-zlib)
GSS-API support:  no      (--with-gssapi)
TLS-SRP support:  no      (--enable-tls-srp)
resolver:         default (--enable-ares / --enable-threaded-resolver)
IPv6 support:     no      (--enable-ipv6)
Unix sockets support: enabled
IDN support:      no      (--with-{libidn,winidn})
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:   no
ca cert path:     no
LDAP support:     no      (--enable-ldap / --with-ldap-lib / --with-lber-lib)
LDAPS support:    no      (--enable-ldaps)
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 POP3 RTSP SMTP TELNET TFTP

我的服务器 cpuinfo:

processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 44
model name      : Intel(R) Xeon(R) CPU           E5649  @ 2.53GHz
stepping        : 2
microcode       : 0x15
cpu MHz         : 2533.423
cache size      : 12288 KB
physical id     : 0
siblings        : 2
core id         : 0
cpu cores       : 2
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 11
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 popcnt aes hypervisor lahf_lm ida arat dtherm
bogomips        : 5066.84
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:

还有我的控制器:

Processor       : ARMv7 Processor rev 2 (v7l)
BogoMIPS        : 298.80
Features        : swp half thumb fastmult vfp edsp thumbee neon vfpv3 tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x3
CPU part        : 0xc08
CPU revision    : 2

使用例如gcc hello_world.c -o hello_world 它为AMD处理器架构而不是ARM编译它。看来我错过了指向 libcURL 库的链接?我感谢每一个帮助。对不起,我的英语不是我的母语。

L/home/nevadmin/dev/gcc -lcurl 的链接正在工作,我可以使用 libcURL 编译 c 代码,但它仍然为 amd64 而不是 arm 编译它。 :/

【问题讨论】:

  • 仅供参考:已经看过Buildroot?它已经提供了 libcurl 配方,它将为您处理大部分交叉编译任务。

标签: c linux gcc cross-compiling libcurl


【解决方案1】:

您需要设置正确的编译器以在配置 curl 时使用。如果您查看 curl 的配置输出,来自

./configure --help

你会在最后看到这个:

...
Some influential environment variables:
  CC          C compiler command
  CFLAGS      C compiler flags
  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
              nonstandard directory <lib dir>
  LIBS        libraries to pass to the linker, e.g. -l<library>
  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
              you have headers in a nonstandard directory <include dir>
  CPP         C preprocessor

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.

您可以使用如下命令行设置这些变量:

CC=arm-linux-gnueabihf-gcc ./configure --build=i586-pc-linux-gnu --host=arm-linux --target=arm-linux --prefix=/home/nevadmin/dev/gcc

(您不需要“sudo”来配置。)

gcc 本身会给你一个 AMD 可执行文件。您需要使用 arm-linux-gnueabihf-gcc 来获取 ARM 可执行文件。

请注意,在您的 curl 配置输出中显示

Compiler:         gcc

这就是为什么您要为您的 AMD 构建 curl 库的原因。 Bibliothek 在英语中被称为“图书馆”。 ;-)

如果您在为 ARM 进行交叉编译时仍然遇到问题,您可以查看交叉编译工具链 ELLCC 的二进制版本。从 0.1.21 版开始,它带有几个预编译的库,包括 curl。这是ChangeLog

【讨论】:

  • 彭尼格顿。谢谢,我可以在arm-linux-gnueabihf-gcc 中更改编译器,但现在我使用arm-linux-gnueabihf-gcc 得到一个否定值。:/usr/include/curl/curlrules.h:142:3: error: size of array ‘curl_rule_01’ is negative curl_rule_01 ^ /usr/include/curl/curlrules.h:152:3: error: size of array ‘curl_rule_02’ is negative curl_rule_02 ^ gcc 编译器可以编译它而不会出现任何错误。我只需要链接库-L/home/nevadmin/dev/gcc -lcurl,但arm-linux-gnueabihf-gcc 在链接和不链接到库的情况下都会带来相同的错误。
  • @Steinfeld:看起来您使用的是 x86 curl 包含文件,而不是您尝试为 ARM 构建的 curl 源中的文件。具体来说,curlbuild.h 是由 configure 生成的。这就是您收到此错误的原因。
  • 是的,我只找到了 1 篇关于此的帖子。这里 (stackoverflow.com/questions/32732753/…) 写的是一样的。但是我尝试了解决方案,但对我没有用。伙计,我想我以后再也不会做交叉编译器了^^
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-12-10
  • 2017-11-07
  • 1970-01-01
  • 2018-01-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多