OpenWrt page for cross-compilation.
There are a few good tutorials out there for cross-compilation of applications for your RB. The steps given below are based on this tutorial. Another good reference is this tutorial. However, not all steps worked for me in the first go, so I am providing my fix!
The first step is to make your application in C (or C++) and test it on your local machine.
The application I am using is a simple C socket based client and server application.
The source files and the corresponding Makefile for the server Makefile and the client Makefile are provided.
Note that this Makefile is used for compilation of your program on the local machine. This Makefile is similar to the one described in this tutorial.
Also note that We have not delved into the cross-compilation part yet!
Now, to check if these applications are indeed working on your system, download both files from server socket program and client socket program and run:
make
You will now have applications named "pawsmaster" and "pawsserver" in the respective directories. To check if they work correctly, in two separate terminals execute:
./pawsserver 5000
followed by:./pawsclient 127.0.0.1 5000
If your output at the client side looks like the one shown below, you are on the right track! The client can keep sending messages to the server and the server keeps responding with a fixed message. You can exit by executing 'Ctrl+c' at the server followed by the client.Please enter the message: hi I am Optimus Prime & I got your message Please enter the message: Bye I am Optimus Prime & I got your message Please enter the message:You are now good to move on to the next section.
Our objective is to make .ipk files for the client and the server that can be installed on your OpenWrt RB.
For this, you need to create Makefiles for OpenWrt. These have been described in this tutorial. The Makefile for the server OpenWrt Makefile or client OpenWrt Makefile are provided. I won't go into the details of creating this Makefile as I am no expert on this.
To cross-compile the applications for OpenWrt, these packages need to be visible in 'make menuconfig'. First download the entire server and client sourcefile directories from here and paste the "pawsmaster" and "pawsclient" directories in the package directory (~/openwrt/attitude_adjustment/package assuming your openwrt buildroot directory is ~/openwrt/attitude_adjustment) of openwrt. Each sourcefile directory must have one Makefile and a directory named "src" containing the .c file and the Makefile. Execute the following set of commands. They are self explanatory.
cd ~/openwrt/attitude_adjustment rm -rf tmp/ make menuconfig
pawsserver and pawsclient will now appear under "Utilities" section. Select both these packages by pressing y.
Now, for the last part, i.e. actual cross-compilation, execute:
make package/pawsserver/compile V=s make package/pawsclient/compile V=s
The .ipk files will be generated in the ~/openwrt/attitude_adjustment/bin/ar71xx/packages directory. The pawsclient_0-1_ar71xx.ipk and pawsserver_0-1_ar71xx.ipk files can be copied to your OpenWrt RB and installed using:
opkg install pawsclient_0-1_ar71xx.ipk opkg install pawsserver_0-1_ar71xx.ipkThe pawsserver and pawsclient binaries will be installed on your OpenWrt RB and can be executed as:
pawsserver 5000
followed by:pawsclient 127.0.0.1 5000
That's it folks!Page maintained by Gaurang Naik.