Openwrt Cross-compiling Helloword

Source: Internet
Author: User

After installing the OPENWRT system on the router, it is necessary to cross-compile the binary program of the MIPS architecture on the host machine and then copy to the router to run the program.


1. Build a cross-compilation environment

Cross-compilation requires a cross-compilation toolchain when compiling OpenWrt. Cross-compiling toolchain and builds, we just need to add the path to the system environment variable.

exportstaging_dir=/path/to/openwrt/trunk/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uclibc-0.9.33.2 /   exportpath= $PATH: $STAGING _dir/bin   

where staging_dir each person's path is not the same, need to change according to their own circumstances.

2. Hello Word Program

Create a new test.c file, add

#include <stdio.h>voidmain () {    printf ("Hello world\n");    return;}

In the terminal, enter the compile command:

./MIPSEL-OPENWRT-LINUX-GCC Test.c-o Test

Finally generate test program, through SCP or other means to copy to the router, run on the router, output


[Email protected]:~#./testhello World

Openwrt Cross-compiling Helloword

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.