Using Eclipse for C/C++ Programming and Debugging

When you develop a new program or adapt an existing program for use on OpenWrt a graphical ide like Eclipse can be useful especially for debugging.

This howto was was developed and tested on a fresh install of Debian 10 in VirtualBox, Eclipse Version: 2020-03 (4.15.0) and a Buffalo WZR-600DHP running OpenWrt 19.07.2. Minor changes may be needed to adapt it to your preferred systems. The directory layout used was


You can certainly use a different layout but you will need to adapt some paths in this howto if you put things somewhere else.

1. Get a functioning build system.

You can use the OpenWrt SDK or you can build your own. If you use the SDK, the instruction page hadn't been updated when this was written but 19.07.2 SDKs were available, this tutorial was tested with this SDK version. If you build your own you need to install the build system and build an image for your platform. This tutorial was tested by checking out v19.07.2 with and configuring for a ATH79 Target System and Buffalo WZR-HP-300H Target Profile.

2. Install Eclipse

Eclipse itself is simple to install, just download the installer from untar it, change into the directory created and run ./eclipse-inst. Select Eclipse IDE for C/C++ Developers, enter the location where you want eclipse installed in the first dialog and enter the location for the workspace in the first dialog after launching eclipse for the first time.

You need to install some eclipse plugins, this is done through the Install New Software... entry on the Help menu. In the Available Software dialog, select --All Available Sites-- in the Work with dropbox and enter remote in the filter textbox. Now find and check

C/C++ Remote Launch Developer Resources
Remote System Explorer End-User Runtime
Remote Launch Targets Developer Resources
Terminal (Console) View Developer Resources

Click Next twice, accept license terms and then click Finish. Allow eclipse to restart itself.

3. Find your toolchain location and prefix and gdb executable.

Toolchain location is <buildsystem root>/staging_dir/toolchain-<whatever>/bin

Toolchain prefix is the part of the filenames in the toolchain directory before the tool name. For example, if you see a file named mips-openwrt-linux-musl-gcc, the toolchain prefix is mips-openwrt-linux-musl-.

The gdb executable is in the toolchain location.

You can find these by using these commands from the buildsystem root:

Toolchain location:

find $(pwd)/staging_dir -type f -name '*-gcc' -printf "%h/\n"|grep -v initial

Toolchain prefix:

find $(pwd)/staging_dir -type f -name '*-gcc' -printf "%f\n"|sed s/gcc//

gdb executable:

find $(pwd)/staging_dir -type f -name '*-gdb'

4. Cross compile hello world

On the main menu bar use File→New→C/C++ Project, select the C++ Managed Build option, click next. Name your project (I used hellocpp), select the Hello World C++ Project and Cross GCC Toolchain, click next three times.

Enter your toolchain location in the Cross compiler path textbox. For the test system using the locally built toolchain this directory is


For the test system using the SDK toolchain this directory is


Enter your toolchain prefix in the Cross compiler prefix textbox The toolchain prefix for the test system is


Click Finish

If you are still on the Welcome Screen, click the Workbench icon in the upper right. Select the project you just created and on the main menubar use Project→Build project and you should see Build Finished. 0 errors, 0 warnings in the Console area.

5. Set up remote target Select Window→Show View→Others from the menubar.

Expand Remote Systems, select Remote Systems from the dialog and click open.

Select File→New→Other from the menubar

Expand Remote System Explorer in the dialog, select Connection and click Next

Select Linux and click next

Enter your routers ipaddress in the Host name text box, click Next,

Check the ssh.files checkbox, select Ssh/Sftp File Service, click Next,

Check the checkbox, click Next,

Check the ssh.shells checkbox, and finally click Finish

6. Access files on remote system

In the Remote Systems Tab expand the entry with your router's ipaddress, expand Sftp files, expand the Root entry

In the Enter Password dialog change the User ID to root, enter your router's password, check Save User ID and Save Password checkboxes. Answer Yes to the questions about connecting over ssh. You can set a password hint if you want but it is not required.

You can now browse the file system on your router in the Remote Systems tab.

7. Debugging on remote system

On the menubar use Run→Debug Configurations, Select C/C++ Remote Application, click on the New Configuration icon

In the main tab:

Click the New button next to the Connection Dropdown, use the dropdown to select ssh, Click OK Enter your router's ipaddress for Host, root for User, Check password based checkbox, enter password in Password text box. Click Finish. Select Remote Host in Connection Dropdown

Enter the program name in the Remote Absolute Path textbox, it must include a path (I use either /hellocpp or /root/hellocpp)

In the debugger tab:

In the GDB debugger text box enter the gdb executable found in step 3

Click Apply, Click Debug

Allow the IDE to switch to the Debug perspective. The program will launch on the router and stop at the first line in main, you can step, continue, etc with the icons on the toolbar, the ide will follow in the source file tab and output will be shown in the Console tab.

8. Using existing makefile programs

9. Debugging existing makefile programs

10. Credits

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
  • Last modified: 2021/10/15 09:06
  • by bobafetthotmail