Using OpenWrt SDK to Build C/C++ Programs

Building C/C++ binaries for LinkIt Smart 7688 development platform requires cross-compilation. Follow these steps to build an example C/C++ ipk file that can be installed with an opkg command.

Environment

Currently only Ubuntu Linux and OS X are supported. Windows with Cygwin is not supported. The following steps assume an Ubuntu Linux environment.

Steps 

  1. Download and unzip the SDK package content from Downloads page.

    The name is quite long and we'll use SDK to denote instead. 

    sudo tar -xvjf SDK.tar.bz2

    Note that sudo is mandatory – without it the file won’t unpack properly. 

    cd SDK
  2. Download and unzip the example package file.
  3. Copy the example helloworld directory to SDK/package folder. The folder structure looks like: 

    SDK/package
       +helloworld              # Name of the package
            -Makefile           # This Makefile describes the package
            +src
                -Makefile       # This Makefile builds the binary
                -helloworld.c   # C/C++ source code
  4. In the SDK directory, enter make package/helloworld/compile to build the package. Once it's built:
    • Navigate to SDK/bin/ramips/packages/base.
    • Find a package file named helloworld_1.0.0-1_ramips_24kec.ipk.
    • Copy the .ipk file to the LinkIt Smart 7688 development board. 
    • In the system console of the board, navigate to the location of the .ipk file and type opkg install helloworld_1.0.0-1_ramips_24kec.ipk.
    • After the installation is complete, type helloworld and you'll see a string Hello world, why won't my code compile?

To cross-compile existing programs or libraries, apply the following in the SDK directory: 

./scripts/feeds update
./scripts/feeds list            # This gives you all the available pacakges
./scripts/feeds install curl    # for example we want to build curl
make package/curl/compile 

References