2015-12-21 64 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

相關問題