2

I'm trying to cross-compile libcurl from a linux ubuntu x86_64 system. My target is an embedded platform based on an arm crotex-m4 NXP micro, flash ram and flash memory are not a concern.

AFAIK libcurl does not require a OS to run over but just wanted a UNIX like flavaour TCP_IP stack. To complain with this point I use a port of LWIP tcp-ip stack for my architecture.

In addition I've already built a library (.a) out from FreeRtos + LWIP + drivers and named it libProject_prova1.a (you will find it in the directives)

Then I wrote a shell script to perform the configure step of the make build that shows as follows:

#! /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

Unfortunatly what I obtain is:

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

In the log file I cannot find an explanation:

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

I'm not understanding where the problem is.

redlib.spec is a nxp custom C library, see: https://community.nxp.com/thread/389152

It's important to use redlib otherwise I will have conflicts with what is defined in LWIP and arm-gnu-none-eabi standard C lib (e.g. redefinition of structure or typedef).

I've tried a simple dumb compilation an linkage to see if I was messing up something in the cpplfags, libs and so on...and noticed that it works. For this example I did the following:

C source:

#include "lwip/netdb.h"


int main(){

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

 gethostbyname(name);
 return 0;

}

compiler directives:

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 

I will kindly appreciate any help you may give me.

Gian
  • 41
  • 4
  • 1
    `./configure --target=${CROSS_COMPILE} --host=${CROSS_COMPILE}` this doesn't look like cross-compiling to me, it looks like you're trying to compile ARM binaries using an ARM compiler on a linux machine, while the configuration thinks it's an ARM machine. Shouldn't the `host` part actually be what the host ARCH really is? – Shark Aug 24 '17 at 15:53
  • @Shark what do you suggest to put as value for `--target; --host; --build`? Maybe I misunderstood what I read here: https://stackoverflow.com/questions/5139403/whats-the-difference-of-configure-option-build-host-and-target – Gian Aug 25 '17 at 10:56
  • I overlooked the `--build` thing when i first looked at your thing.. Having all three (`--target`, `--host`, `--build`) implies a Canadian Cross or some variation of it. `--host` and `--build` should be the machine you're building on - the Ubuntu machine. `--target` should be the `$(CROSS_COMPILE)` – Shark Aug 25 '17 at 12:10
  • your current script is configuring in a way that you're using your ubuntu machine to make something, that will be built and then ran on `$(CROSS_COMPILE)` – Shark Aug 25 '17 at 12:11

0 Answers0