I thought that it would be great to have RHIDE running on my Pocket CHIP for doing simple C/C++ development on the go, as TUIs (Text-based User Interfaces) were pretty simple and could work in really low resolutions, but unfortunately CHIP’s ARM architecture was completely foreign to RHIDE’s build scripts, and it refused to compile.
I’m definitely no Linux guru, but I reckoned that adding the architecture to the build script wasn’t going to be easy, especially since it apparently had several architecture-dependent libraries, modules, etc, so I embarked on a quest to find another text-based IDE for Linux, and that’s how I found Motor.
Sure, the project is 12 years old (last “build” is 3.4.0 from February 2005, and still more recent than RHIDE), but I thought that perhaps it could still work on a relatively modern Linux distribution, and to my surprise, it did (with a few gotchas, though).
Before you can develop on your Pocket C.H.I.P you will need to install gcc and a few standard libraries and tools for development, which you can do with ease by running
sudo apt-get install build-essential.
Motor also uses ncurses, a library that facilitates writing text-based UIs, so you’ll also need to
sudo apt-get install libncurses-dev.
ALSO, for the auto-make capabilities of Motor to work, you’ll need to install automake, and since we are already installing packages, it would be a good time to install that as well, with -you guessed-
sudo apt-get install automake.
Building Motor from the latest “web” version
On the project’s page you will find links to updated pre-built packages and, of course, its source code. You can download the “latest” version directly from your Pocket C.H.I.P (or remotely from a ssh shell) with:
After you’ve downloaded the package, unpack it with
tar xzvf motor-3.4.0.tar.gz and go into the folder with
cd motor-3.4.0. Once there run
If you’ve installed all the packages before, this step should succeed with no problems. Now you can go ahead and run
make if you want, but you’ll find that after compiling a few modules the process will abort with a couple of errors.
Thankfully all the problems in the source code are easy to fix. The first problem is that they use their own implementation of strndup. You’ll need to edit parser/include/strfn.h and parser/src/strfn.c and comment out (or remove) their declaration and implementation of the function, as it’s already part of the string.h standard library.
The second problem is a missing declaration of a datatype in src/debugger/motordebugger.cc, which can be solved by adding
#include <memory> among the includes at the top part of the file.
With those changes the project should compile just fine with
make and then you can run
sudo make install to properly install Motor in your system.
After you’ve installed it, you can run it from the terminal, and create your first project.
It will take a while to generate the project files, but after it’s done it will open it for you. You can go to the Project menu and browse the files, and if you selected “Generate initial source” in the step before, you should have a single source file already there, with a really simple program that types its own name, and the name of the author (automatically taken from your Linux username). If you did not, you can add your own files and write your code.
You can build and run that from the top menu, which you invoke pressing F10 (first picture of this post). Motor will also switch to the terminal output when you run the program.
Bonus: Building the project from the latest Git version
There’s also an apparently more updated GIT repository, based on the 3.4.0 release. if you feel adventurous and you have git installed on your C.H.I.P you can build that version instead. The first step is running:
git clone https://github.com/rofl0r/motor.git.
This version doesn’t have a configure script, and will compile just fine, provided that you edit the Makefile to remove the -lintl flag from the LIBS variable before. After this change the project builds normally with
make, and no changes to the source are required.
However, in my tests this version doesn’t seem to run or build my code at all, and doesn’t seem to report its own version number properly (it says 0.0.0 on the top bar). I don’t know if this is because I installed this version over the other one, but I definitely had to revert to the other build to have a working IDE.
Feel free to experiment with the git version though, as it seems more recent and does not require messing with source files, but I’d recommend you to try building it on a clean CHIP, without the other version installed before. If that works please let me know; I may test that in a future, but so far I’m happy with the version from the project’s page.
Bonus 2: Running Motor remotely via ssh Shell
Remote ssh access is something I normally have enabled on my Pocket CHIP to easily run commands on it. On my Windows PC I use Putty as the ssh client, and this works great out of the box for running regular commands on my C.H.I.Ps, but if you want to run ncurse-based programs (like Motor) on the terminal, you’ll need to properly configure the character encoding. For me the following settings did the trick:
With that setup I can now run and use Motor remotely (not really useful for a Pocket C.H.I.P, but may come in handy for a headless C.H.I.P development server):
I think that Motor runs reasonably fine, and it’s quite easy to use. It will take you a bit to get used to the keys, but the most useful thing to remember is that F10 brings up the menu, from which you can do pretty much everything, and also that pressing ESC twice is needed to cancel some actions or go back from any screen.
It seems to have several advanced functions like integrated and configurable version control, debugger, creating binary packages from your project, etc, which is really amazing for such an “old-school” IDE.
There are some issues here and there with the program, at least on my device. For instance the first time I built a project it took several attempts for the program to generate the files and open the project for me, and sometimes the UI glitches a bit, but that goes away on its own, and could totally be a problem with the ncurses port for the C.H.I.P, and not necessarily with Motor. My issues with my first project could be related to the fact that I didn’t have automake installed the first time I tried, and then I had to remove the project and create it again several times for it to work. It has worked fine after that, though.
Overall I’m quite happy with the way it runs, and brings back so many memories of the text-based development environments I used on DOS over the years like Turbo C, Turbo Pascal, QB, DJGPP, etc.
And of course, it’s never a bad thing to have a small IDE you can use from your local or remote terminal.