OpenWrt Forum Archive

Topic: Help:Corss compile simple c file using Openwrt,but failed.

The content of this topic has been archived on 17 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi,
I am new to corss compile c file for openwrt. So maybe this looks simple to you,but I really want to try to compile a single
c file which can run on my router (DB120,BRCM6358 chip).

Yesterday I downloaded OpenWrt-SDK-brcm63xx-for-Linux-i686-gcc to Ubuntu11.10 (VMware machine), and refered to OpenWrt WIKI here http://wiki.openwrt.org/doc/devel/crosscompile.

I extracted sdk to /home/x86/Share/OpenWrt-SDK, then added the toolchain directory to the PATH environment variable
and set the STAGING_DIR environment variable to the toolchain dir and export it. After modifing /home/x86/.profile, Using
source  /home/xx86/.profile  to make it work.

Here is my $PATH

bash: export: `/home/x86/Share/OpenWrt-SDK/staging_dir/toolchain-mips_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/bin:/home/x86/Share/OpenWrt-SDK/staging_dir/toolchain-mips_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/bin:/home/x86/Share/OpenWrt-SDK/staging_dir/toolchain-mips_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games': not a valid identifier

x86@x86-pc:~/Share$ export $STAGING_DIR
bash: export: `/home/x86/Share/OpenWrt-SDK/staging_dir/toolchain-mips_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/bin': not a valid identifier

After doing this, I write a helloworld, Makefile and put it in /home/x86/Share/helloworld

//this is the hellowolrd source

#include <stdio.h>
#include <unistd.h>
int main(void)
{
printf("Hello world!\n\n");
return 0;
}

Next is the content of Makefile

helloworld: helloworld.o
    $(CC) $(LDFLAGS) helloworld.o -o helloworld
helloworld.o: helloworld.c
    $(CC) $(CFLAGS) -c helloworld.c

# remove object files and executable when user executes "make clean"
clean:
    rm *.o helloworld

compiled it using terminal, and it failed.

x86@x86-pc:~/Share/helloworld$ make CC=mips-openwrt-linux-gcc LD=mips-openwrt-linux-ld
mips-openwrt-linux-gcc  -c helloworld.c
mips-openwrt-linux-gcc  helloworld.o -o helloworld
/home/x86/Share/OpenWrt-SDK/staging_dir/toolchain-mips_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/bin/../lib/gcc/mips-openwrt-linux-uclibc/4.3.3/../../../../mips-openwrt-linux-uclibc/bin/ld: cannot find -lgcc_s
collect2: ld returned 1 exit status
make: *** [helloworld] Error 1

So I don't know what to do about this, if you kown how to deal with this, please help my.

ANY REPLY WILL BE APPRECIATED!

Complement:I have installed the dependence which was said on openwrt wiki.

(Last edited by cb049 on 18 Apr 2012, 05:00)

Tht question above was worked out. I re-configured on my physical mechine and the error never came out.

The discussion might have continued from here.