在freeRtos和LWIP上交叉编译libcurl for arm

时间:2017-08-24 15:44:33

标签: c arm cross-compiling libcurl

我试图从linux ubuntu x86_64系统交叉编译libcurl。 我的目标是基于arm crotex-m4 NXP micro,flash ram和flash memory的嵌入式平台不是一个问题。

AFAIK libcurl不需要运行操作系统,但只需要一个类似于flavaour TCP_IP堆栈的UNIX。为了抱怨这一点,我使用了一个LWIP tcp-ip stack端口作为我的架构。

此外,我已经从FreeRtos + LWIP +驱动程序中构建了一个库(.a),并将其命名为 libProject_prova1.a (您将在指令中找到它)

然后我写了一个shell脚本来执行 make build 的配置步骤,如下所示:

#! /bin/sh

export PATH=/usr/local/mcuxpressoide-10.0.2_411/ide/tools/bin:$PATH
PATH=/home/user/Documents/MCUXpresso_10.0.2_411/workspace/libProject_prova1/Release:$PATH

export ROOTDIR="${PWD}"
export MBEDDIR=/home/user/Desktop/mbed_TLS_NXP/build
export PROJDIR=/home/user/Documents/MCUXpresso_10.0.2_411/workspace/libProject_prova1
cd ./curl-7.55.0


export CPPFLAGS="-DUSE_LWIPSOCK -D__REDLIB__ -DLWIP_DNS=1 -DUSE_RTOS=1 -DCR_INTEGER_PRINTF -DSDK_DEBUGCONSOLE=0 -D__MCUXPRESSO -D__USE_CMSIS -DNDEBUG -DFSL_RTOS_FREE_RTOS -DSDK_OS_FREE_RTOS -DCPU_LPC54608J512ET180 -DCPU_LPC54608J512ET180_cm4 -I${PROJDIR}/lwip/src/include/lwip -I${PROJDIR}/lwip/src/include/lwip/priv -I${PROJDIR}/lwip/src/include/lwip/prot -I${PROJDIR}/lwip/src/include/netif -I${PROJDIR}/lwip/src/include/netif/ppp -I${PROJDIR}/lwip/src/include/netif/ppp/polarssl -I${PROJDIR}/lwip/src/include/posix -I${PROJDIR}/lwip/src/include/posix/sys -I${PROJDIR}/lwip/port -I${PROJDIR}/lwip/port/arch -I${PROJDIR}/lwip/src -I${PROJDIR}/lwip/src/include -I${PROJDIR}/lwip/src/netif -I${PROJDIR} -I${PROJDIR}/drivers -I${PROJDIR}/utilities -I${PROJDIR}/freertos -I${PROJDIR}/CMSIS -I${PROJDIR}/startup -I${MBEDDIR}/include/mbedtls"

export CFLAGS="-O0 -fno-common -g3 -Wall -c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -specs=redlib.specs"
export LDFLAGS="-L${MBEDDIR}/lib -L${PROJDIR}/Release"
export LIBS="-lProject_prova1"

export CROSS_COMPILE=arm-none-eabi
export AR=${CROSS_COMPILE}-ar
export AS=${CROSS_COMPILE}-as
export LD=${CROSS_COMPILE}-ld
export RANLIB=${CROSS_COMPILE}-ranlib
export CC=${CROSS_COMPILE}-gcc
export NM=${CROSS_COMPILE}-nm
export PREFIX=${ROOTDIR}/build

./configure --target=${CROSS_COMPILE} --host=${CROSS_COMPILE} --prefix=${ROOTDIR}/build --build=x86_64-linux-gnu --without-ssl --with-mbedtls --enable-static --disable-shared --disable-ftp --disable-file --disable-pop3 --disable-smb --disable-smtp --disable-imap --disable-ldap --disable-ldaps --disable-dict --disable-telnet --disable-tftp --disable-manual --disable-ipv6 --disable-unix-sockets --disable-versioned-symbols --disable-ares --disable-sspi --disable-gopher --without-zlib --without-libssh2 --without-ca-bundle -without-ca-path --without-libidn --without-librtmp --without-libidn

不幸的是,我得到的是:

checking for grep... /bin/grep
checking for egrep... /bin/grep -E
checking for a BSD-compatible install... /usr/bin/install -c
checking for arm-none-eabi-gcc... arm-none-eabi-gcc
checking whether the C compiler works... no
configure: error: in `/home/user/Desktop/curl_libProject_prova1/curl-7.55.0':
configure: error: C compiler cannot create executables
See `config.log' for more details

在日志文件中我找不到解释:

configure:4781: checking whether the C compiler works
configure:4803: arm-none-eabi-gcc -O0 -fno-common -g3 -Wall -c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb --specs=redlib.specs -D__REDLIB__ -DUSE_LWIPSOCK -DLWIP_DNS=1 -DUSE_RTOS=1 -DCR_INTEGER_PRINTF -DSDK_DEBUGCONSOLE=0 -D__MCUXPRESSO -D__USE_CMSIS -DNDEBUG -DFSL_RTOS_FREE_RTOS -DSDK_OS_FREE_RTOS -DCPU_LPC54608J512ET180 -DCPU_LPC54608J512ET180_cm4 -I/home/user/Documents/MCUXpresso_10.0.2_411/workspace/libProject_prova1/lwip/src/include/lwip -I/home/user/Documents/MCUXpresso_10.0.2_411/workspace/libProject_prova1/lwip/src/include/lwip/priv -I/home/user/Documents/MCUXpresso_10.0.2_411/workspace/libProject_prova1/lwip/src/include/lwip/prot -I/home/user/Documents/MCUXpresso_10.0.2_411/workspace/libProject_prova1/lwip/src/include/netif -I/home/user/Documents/MCUXpresso_10.0.2_411/workspace/libProject_prova1/lwip/src/include/netif/ppp -I/home/user/Documents/MCUXpresso_10.0.2_411/workspace/libProject_prova1/lwip/src/include/netif/ppp/polarssl -I/home/user/Documents/MCUXpresso_10.0.2_411/workspace/libProject_prova1/lwip/src/include/posix -I/home/user/Documents/MCUXpresso_10.0.2_411/workspace/libProject_prova1/lwip/src/include/posix/sys -I/home/user/Documents/MCUXpresso_10.0.2_411/workspace/libProject_prova1/lwip/port -I/home/user/Documents/MCUXpresso_10.0.2_411/workspace/libProject_prova1/lwip/port/arch -I/home/user/Documents/MCUXpresso_10.0.2_411/workspace/libProject_prova1/lwip/src -I/home/user/Documents/MCUXpresso_10.0.2_411/workspace/libProject_prova1/lwip/src/include -I/home/user/Documents/MCUXpresso_10.0.2_411/workspace/libProject_prova1/lwip/src/netif -I/home/user/Documents/MCUXpresso_10.0.2_411/workspace/libProject_prova1 -I/home/user/Documents/MCUXpresso_10.0.2_411/workspace/libProject_prova1/drivers -I/home/user/Documents/MCUXpresso_10.0.2_411/workspace/libProject_prova1/utilities -I/home/user/Documents/MCUXpresso_10.0.2_411/workspace/libProject_prova1/freertos -I/home/user/Documents/MCUXpresso_10.0.2_411/workspace/libProject_prova1/CMSIS -I/home/user/Documents/MCUXpresso_10.0.2_411/workspace/libProject_prova1/startup -I/home/user/Desktop/mbed_TLS_NXP/build/include/mbedtls -L/home/user/Desktop/mbed_TLS_NXP/build/lib -L/home/user/Documents/MCUXpresso_10.0.2_411/workspace/libProject_prova1/Release conftest.c -lProject_prova1 >&5
configure:4807: $? = 0
configure:4845: 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:4850: error: in `/home/user/Desktop/curl_libProject_prova1/curl-7.55.0':
configure:4852: error: C compiler cannot create executables
See `config.log' for more details

我不明白问题所在。

redlib.spec 是一个nxp自定义C库,请参阅:  https://community.nxp.com/thread/389152

使用 redlib 非常重要,否则我将与LWIP和arm-gnu-none-eabi标准C lib中定义的内容发生冲突(例如重新定义结构或typedef)。

我尝试了一个简单的哑编译链接,看看我是否搞砸了cpplfags,libs等等的东西......并注意到它有效。 对于此示例,我执行了以下操作:

C来源:

#include "lwip/netdb.h"


int main(){

 char* name="www.google.it";

 gethostbyname(name);
 return 0;

}

编译器指令:

export PATH=/usr/local/mcuxpressoide-10.0.2_411/ide/tools/bin:$PATH
PATH=/home/user/Documents/MCUXpresso_10.0.2_411/workspace/libProject_prova1/Release:$PATH
export PROJDIR=/home/user/Documents/MCUXpresso_10.0.2_411/workspace/libProject_prova1
export CPPFLAGS="-DUSE_LWIPSOCK -D__REDLIB__ -DLWIP_DNS=1 -DUSE_RTOS=1 -DCR_INTEGER_PRINTF -DSDK_DEBUGCONSOLE=0 -D__MCUXPRESSO -D__USE_CMSIS -DNDEBUG -DFSL_RTOS_FREE_RTOS -DSDK_OS_FREE_RTOS -DCPU_LPC54608J512ET180 -DCPU_LPC54608J512ET180_cm4 -I${PROJDIR}/lwip/src/include/lwip -I${PROJDIR}/lwip/src/include/lwip/priv -I${PROJDIR}/lwip/src/include/lwip/prot -I${PROJDIR}/lwip/src/include/netif -I${PROJDIR}/lwip/src/include/netif/ppp -I${PROJDIR}/lwip/src/include/netif/ppp/polarssl -I${PROJDIR}/lwip/src/include/posix -I${PROJDIR}/lwip/src/include/posix/sys -I${PROJDIR}/lwip/port -I${PROJDIR}/lwip/port/arch -I${PROJDIR}/lwip/src -I${PROJDIR}/lwip/src/include -I${PROJDIR}/lwip/src/netif -I${PROJDIR} -I${PROJDIR}/drivers -I${PROJDIR}/utilities -I${PROJDIR}/freertos -I${PROJDIR}/CMSIS -I${PROJDIR}/startup"


arm-none-eabi-gcc -O0 -fno-common -g3 -Wall -c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -D__REDLIB__ -specs=redlib.specs main.c ${CPPFLAGS} -L${PROJDIR}/Release -lProject_prova1 -o main 

我将非常感谢您给予我的任何帮助。

0 个答案:

没有答案