Eclipse-AutoTools project in Ubuntu and a small head scratch

In this article I will try to demonstrate a very simple way to start an autotools project with Eclipse in Ubuntu. This is very simple except a peculiar problem which may wast your half of the day.

While working with autotools projects in Ubuntu 12.0.1 recently I have faced a strange problem. In short the problem is: In Eclipse while auto-configuration of autoreconfig tool, it fails with the following message: sh: 0: Can't open autoreconf. This happens because of some internal configuration problem in Eclipse. It can easily be resolved with a workaround which will be demonstrated in this article later.

First we proceed to create a C project with AutoTools in Eclipse. I will demonastrate less as I will be using lots of screen-short. After all “A picture is worth a thousand words”.

Then expand the “GNU Autotools” node in the project type and select the basic Hello world Autotools project. Remember the toolchain should be “GNU Autotools Toolchain” and name the project (ie. HelloAuto)

A simple HelloAuto project will be created along with other supporting files and the HelloAuto.c will be created with bare minimum test code.

At this point you can configure the project from Project -> Reconfigure Project.

This configuration should be successful except on some versions of Ubuntu. In the versions of Ubuntu where the dash is the default shell in stead of bash you are supposed to end up with an error with the message: sh: 0: Can't open autoreconf.

But fortunately there is a work around to get rid of this problem.

Work around

Go to your personal home(in Ubuntu ie. #cd ~). Create a bin folder in your personal home (#mkdir bin). Finally in this bin directory create a link of /bin/bash with sh (#ln -s /bin/bash sh).

Then go back to the personal home (#cd ~) and then edit the .bashrc file with adding the line export PATH=/home/rizvi/bin:$PATH at the end if the file. Notice that I have rizvi as my personal home, which you have to change with your personal home directory name.

After all this fixing, reconfigure the project again from Project -> Reconfigure Project.

If all has been done well and good, then the project should autoreconfigure successfully. After configuration notice that there will be couple of new files generated for you as part of configuration.

In case if you don’t find the successful message in the console, try selecting the “CDT Global Build Console”.

Next time to build. Build from Project -> Build All.

If the build is successful you should get a successful build message.

Now time to run the project from – Right click on project folder -> Run As -> Local C/C++ Application.

You should see the program running if you are lucky other wise you may see an error message like this.

But don’t worry about this message. This is just because your last build could not create the binary to run.

Build the project again from Project -> Build Project. Now run the project again and you should see the running program in the “CDT Global Build Console”.

Now with this article if you can run an autotools project in Ubuntu – I would be glad to hear from you. But if you face any new issue or find any improvement – feel free to let me know or comment.


One thought on “Eclipse-AutoTools project in Ubuntu and a small head scratch

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s