2015-12-21 60 views
1

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

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处理器架构而不是手臂。看来我错过了libcURL的库链接?我感谢每一个帮助。对不起我的英语,这不是我的母语。

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

+0

仅供参考:已经看过[Buildroot](https://buildroot.org/)?它已经提供了* libcurl *配方,它将为您处理大部分交叉编译任务。 – yegorich

回答

2

您需要设置正确的编译器以便在配置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可执行文件。

请注意,在你的卷曲的配置输出它说

Compiler:   gcc 

这就是为什么你获得你的AMD建立了一个curl库。 Bibliothek被称为英文的“图书馆”。 ;-)

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

+0

彭尼希顿。谢谢,我可以在'arm-linux-gnueabihf-gcc'中更改编译器,但是现在我得到了一个使用arm-linux-gnueabihf-gcc的负面版本:'/usr/include/curl/curlrules.h: 142:3:错误:数组'curl_rule_01'的大小为负数curl_rule_01 ^/usr/include/curl/curlrules。h:152:3:错误:数组'curl_rule_02'的大小为负数curl_rule_02 ^' 'gcc'编译器可以毫无误差地编译它。我只需要链接'-L/home/nevadmin/dev/gcc -lcurl'库,但是'arm-linux-gnueabihf-gcc'会在链接到库时带来相同的错误。 – Steinfeld

+0

@Steinfeld:它看起来像你正在使用你的x86卷曲包含文件,而不是你试图为ARM构建的curl源文件。具体来说,curlbuild.h由configure生成。这就是你得到这个错误的原因。 –

+0

是的,我发现只有1篇关于这个。这里(http://stackoverflow.com/questions/32732753/cross-compile-libcurl-for-arm-linux-gnueabi-gcc)它写的是一样的。但我尝试了解决方案,但它并没有为我工作。我认为在这之后^^将永远不会做交叉编译器 – Steinfeld

相关问题