Issue
I am an enthusiastic C/C++ programmer who is new to this firmware customization field of study. For my final year project, I am developing a solution to enhance the packet switching of a router and selected OpenWRT as my open-source firmware. I have been struggling a bit to set up the environment and would like to get your expert opinion on if I am on the correct path.
I followed the following steps to get openWRT to my local PC. (http://wiki.openwrt.org/doc/howto/buildroot.exigence).
In the make menuconfig, I have selected, - Advanced configuration Options -Automatic rebuild of packages -ToolChain Options -Build gdb -Build the OpenWRT Image Builder -Build the OpenWRT SDK -Build the OpenWRT based ToolChain
and saved the config and ran the commands, - make tools/install - make toolchain/install
Then in Netbeans, I added a new tool collection from Tools -> Options -> C/C++
and gave the base directory as '/openwrt/openwrt/toolchain'
and the C Complier as '/usr/bin/gcc'
Can you experts please advise me if I have done anything wrong? Is this sufficient to develop and compile a new C class to the openWRT firmware so that I can rebuild an image to be flashed into a router?
Your advice is much appreciated dear experts. I was struggling with this issue for quite some time :)
Thanks again :)
EDIT
The issue is that when i set the folder
/openwrt/openwrt/staging_dir/toolchain-i386_gcc-4.5-linaro_uClibc-0.9.32/i486-openwrt-linux
which refers in the tutorial http://downloads.openwrt.org/docs/eclipse.pdf to be set as the cross compiler in the IDE it given an error stating that no Compiler is found in both the eclipse and Netbeans.
But it works when I point to the /openwrt/openwrt/toolchain
directory.
My query is that is it okay to press on with the development and use the Compiler within the toolchain folder to compile the project?
EDIT 2
The output I get when I run the command
find ./staging_dir -path "./staging_dir/toolchain*" -name *openwrt-linux
within the openwrt folder as suggested by TheCodeArtist
is
./staging_dir/toolchain-mips_34kc_gcc-4.6-linaro_uClibc-0.9.33.2/mips-openwrt-linux
EDIT 3
EDIT 4
Solution
Provide the appropriate toolchain directory for the target architecture (x86, arm, mips etc.) based on the device you intend to run the resulting executables as the Base Directory
.
Next provide the relative path/filenames of the individual commands for C compiler
, C++ compiler
etc. These will be relative paths(including the filenames) to the appropriate binaries within the toolchain directory specified above.
How to verify the toolchain settings?
Using the IDE, compile a simple hello-world.c
program. Something like
/* hello-world.c */
int main()
{
return (42);
}
Give a Build
using the IDE and check the compilation output window. Understand the errors if any and modify the configuration options accordingly.
Once a build succeeds and it will result in a binary hello-world
within the project directory. Open a new terminal and run the file
command on newly generated binary to verify that it is indeed built for the target architecture. For example a binary built for x86-64 would show.
$ file hello-world
hello-world: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped
In your case i assume it would be a MIPS
executable if the mips toolchain and compiler are properly configured within the IDE settings.
Answered By - TheCodeArtist
Answer Checked By - Marilyn (JavaFixing Volunteer)