RepRapDeveloperInstallLinux

From RepRap
Revision as of 04:20, 19 July 2015 by Glenn (talk | contribs) (catchg Category:Reprap host software)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Are you itching to print out beautiful, fun, amazing, interesting, or useful physical objects? Skip this page. Try Installing RepRap on your computer instead.

Do you want to help us improve our software? Excellent, you're in the right place. This page describes how to set up a development environment to work on our software.

Development Snapshot

In case you're just looking for a more recent version of the host software, try the development snapshot File:Reprap-mendel-current.zip. It'll be updated from time to time.

Even better, jmarsden has started doing automatic nightly builds.

Downloading and installing the RepRap development software under Linux or Unix

RepRap uses a large number of open-source software packages for development, and quite a few when it runs. This page describes how to take a standard Linux/Unix installation and prepare it for RepRap development. It then describes how to download and set up all the RepRap software.

Note that for many of these installations you will need the superuser password for your machine.

When I wrote this page I took a raw Linux PC and set it up, logging everything I did. The Linux I used was Ubuntu. The only packages loaded when I started were X Windows and associated software that Ubuntu installs when you ask it to build a desktop environment. It should be easy to adapt the descriptions below for other Unix systems.

To do most of the following work it is useful to have three windows open on your computer:

  • A terminal window,
  • A terminal window where you are logged in as the superuser, and
  • A web browser with this page displayed.

Then you can copy-and-paste the commands below into the appropriate terminal window. Be careful what you type in the superuser window, especially if you are not a Unix expert - you can damage your system with an ill-judged command...

When you have finished each section below close all windows and programs that you have opened except those three.

Where does stuff go?

This depends on your system and its conventions. You will probably want to install everything system-wide (that is, not just in your own space) so everyone who uses your computer can work with RepRap. On Linux systems this means creating directories in /usr/local to put installation files in. Some Unix systems also install files in /opt.

When you create directories in /usr/local (or /opt) start them with capital letters. Then it's easy to keep track of everything as all other directories in there start with lower case.

If you want another location, e.g. your Home directory, that's fine as well. The RepRap package comes with everything required, just unpack it where you want it to go.

Initial packages

You'll need a copy of Subversion:

You may find that your Linux distribution already has this installed. If not, sudo apt-get subversion will get it for you on Debian and Ubuntu systems.

Java

RepRap's controlling software is written in Java, and also the Art of Illusion design package for three dimensional objects uses it, so next we need a Java development environment. The following method of getting one should be clean, in that it is easy to separate it from any Java that you already have on your system.

Java Development Kit (JDK) on Ubuntu

As the superuser or system administrator install and configure the latest Sun Java JDK package. The simplest way to do this is to use the Synaptic Package Manager (System > Administration > Synaptic Package Manager). If you search for Java you will find lots available - go for the one with Sun in its name that has the biggest version number...

If you have problems, see this useful website.

If Ubuntu's Sun Java packages are installed as above, do not do the Generic Linux install detailed below.

Java Development Kit (JDK) on Generic Linux

Go to the Sun Java Downloads Page. To start with you want The J2SE Java Runtime Environment (JRE). Click on the "Accept Licence" button (you can even read the licence, if you like, but remember: Life Is Short...), then click on the Linux self-extracting file (which will be called something like j2re-1_4_2_13-linux-i586.bin; the numbers will change as the versions change) and save it as a file in your home directory.

Next, as the superuser, create a directory to put Java downloads in and move the file you just got into it:

    # cd /usr/local
    # mkdir Java
    # cd Java
    # mv ~your-id/j2re-1_4_2_13-linux-i586.bin .    
(Don't forget the . !)

Where your-id is your user ID on your system, and the j2re-1_4_2_13-linux-i586.bin file is the one you just downloaded.

Make sure the file is executable, then run it:

    # chmod +x j2re-1_4_2_13-linux-i586.bin
    # ./j2re-1_4_2_13-linux-i586.bin

This will ask you to genuflect before the licence (again), and will then extract the files into a subdirectory that will end up being called something like /usr/local/Java/j2re1.4.2_13.

Finally, the file /usr/local/Java/j2re1.4.2_13/bin/java needs to be in the search path for executables. The simplest way to do this is to create a symbolic link to it from /usr/local/bin:

    # cd /usr/local/bin
    # ln -s /usr/local/Java/j2re1.4.2_13/bin/java

Building without Eclipse

If you just want to build the latest and greatest or prefer some other editor, you don't need Eclipse.

The first time, do:

cd ~
svn checkout \
  https://reprap.svn.sourceforge.net/svnroot/reprap/trunk/reprap/host \
  reprap-host
svn checkout \
  https://reprap.svn.sourceforge.net/svnroot/reprap/trunk/mendel
cd reprap-host
./host-package-release

To update after the initial setup:

cd ~/reprap-host
svn update
./host-package-release

You'll find the finished and complete package in the release/ directory. A ZIPed one for distribution and an unpacked one ready for use.

If you're on 64-bit Linux, you need to apply the tweaks for this platform after each build.

Eclipse: the Java development platform

Installing Eclipse on Ubuntu

Ubuntu provides Eclipse as a maintained package, which means things get updated and upgraded as part of the automatic maintenance processes. Install it using the package manager, or with the following command line typed at a console:

sudo apt-get install eclipse

If Ubuntu's Eclipse package is installed as above, do not do the Generic Linux install detailed below. You will however need to do the Subclipse install.

Installing Eclipse on Generic Linux

Next you need the Eclipse Java development platform. Follow the Download link from that page. This should be smart enough to spot what sort of computer you are on, and to give you the option of downloading the Eclipse SDK 3.2.1 for Linux (the numbers may change if they're up to a different version). Click on that, and then on a mirror site that is geographically close to you. Save the resulting compresed tarball (which will be called something like eclipse-SDK-3.2.1-linux-gtk.tar.gz) in your home directory.

Next, as the superuser once more, move the file to the /usr/local/Java directory and unpack it:

    # cd /usr/local/Java
    # mv ~your-id/eclipse-SDK-3.2.1-linux-gtk.tar.gz .
    # tar -xvzf eclipse-SDK-3.2.1-linux-gtk.tar.gz

This will create a subdirectory under /usr/local/Java called eclipse and put lots of files in it.

The file /usr/local/Java/eclipse/eclipse needs to be run to get Eclipse working, but it likes to be in its own directory when it does so. Consequently type the following:

    # cd /usr/local/bin
    # cat > eclipse
    #!/bin/sh
    cd /usr/local/Java/eclipse
    ./eclipse

Finish with <CTRL> C on a new line. This is a little shell script that moves to where you need to be then runs Eclipse. Note that the # before the exclamation mark is part of the file.

Finally make sure it has the right permissions:

    # chmod +x eclipse

To test it, as you (not the superuser) just type the eclipse command, which will run the script you just created:

    $ eclipse

This should produce a blue I-am-starting-up window, then ask you if you want to create a workspace in your home directory (say yes), then give you the development platform window.

Subclipse: version control under Java

All of RepRap is maintained under the Subversion version-control system. This allows easy updating of source code, and also roll-back to previous versions should that be needed. The section of Subversion that works in Eclipse is called Subclipse, and it installs itself from within Eclipse.

First, run eclipse as root (to install Subclipse system-wide):

    # sudo eclipse

Then, follow the instructions on the Subclipse webpage. Install Subclipse 1.2.x, not Subclipse 1.4.x (which doesn't seem to work as well as the earlier version).

Note: In Step 6 of those instructions, be careful to only select Subclipse, not any other plugins such as Mylar which may be visible on that screen.

Note: If you are behind a firewall or use an HTTP proxy server you may need to configure Eclipse so that it knows about that before you install Subclipse. In Eclipse go to the menu: Window -> Preferences -> Install/update and enter the location of the HTTP proxy machine on your network and its port number (usually 3128, but check with your network manager if you are not sure about this). If you are a private individual on broadband you should have a direct connection and this won't be needed.

If you get errors suggesting that the default SVN client cannot be found, make suer you have installed the libsvn-java package. If that doesn't cure it, find your eclipse.ini file and add the following lines directly after the -vmargs line:


    -Djava.library.path=/usr/share/java/
    -Djava.library.path=/usr/lib/jni/

Using the NetBeans IDE for GUI development

If you don't find the idea of a mouse listener mildly amusing, you might like to get into the black hole of GUI development. You can skip this step if prefer to linger just outside the event horizon.

Some of the later GUIs have been developed using NetBeans 6.0.1. This package enables a WYSIWYG development environment which, with a bit of practice, is superb. As with all GUI editors, however, it locks us into using this software by associating an XML file to segments of the GUI classes. But the stability makes it a worthy trade off. This means you must edit the recent GUIs in Netbeans. Here's how to set all that up, assuming that you have already completed the eclipse setup above.

The RepRap Java programs

Now (finally...) you can download part of the RepRap project - all the RepRap Java source code.

As you (not the superuser) run eclipse.

In Eclipse go to the menu: Window -> Open Perspective -> Other... and you will get a menu containing (among other things) SVN Repository Exploring. Select that and click on OK. It should open a window called SVN Repository. Right mouse click in that window and select New -> Repository location.

Type the URL for the RepRap project at SourceForge:

    https://reprap.svn.sourceforge.net/svnroot/reprap/trunk

You may be asked to accept an encryption signature, and it will then enter the main part of the RepRap project in the SVN Repository window.

If you open this (the little triangle on the left) you will see all the sections of the RepRap project. Select reprap then host, right-mouse-click, and select checkout. It will ask you if you want to put this in Reprap in your main workspace (say yes), and it will then download all the RepRap software for driving the RepRap machine from your computer as a host.

Top right in the Eclipse window is a tag that says SVN (this is telling you that you are using Subversion at the moment) and a >> symbol. Click on that >> symbol and select Java. This takes you back to the Java language view, in which you should now have installed the RepRap host software. Open it up; the source code is under src. Explore...

You will almost certainly have to increase the size of the virtual machine when the RepRap software runs.

Set that under:

  Run > Run... > Java Application > Argument > VM Arguments

What you set depends on the resources available in your computer to a certain extent. I use

  -Xms256m
  -Xmx1024m

Which starts the heap at 256M and allows it to grow to 1 GB.

You will have to add lib/system-dependent/linux-i386 under the installation directory to the path that the system uses to search for library files. Type the following to run eclipse:


$ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/workspace/Reprap/lib/system-dependent/linux-i386

$ export LD_LIBRARY_PATH

$ eclipse

Alternatively, add the first two lines to the file .bashrc in your home directory.

To run RepRap in Eclipse right mouse click on Reprap > src > org.reprap > Main.java and select Run as > Java application.

Art of Illusion

RepRap uses Art of Illusion as a 3D design tool. Click on that link and go to downloads then to Linux. Follow the download instructions.

RepRap uses a number of additional scripts in AoI, so you need to run it in order to download them too. You must do this as the superuser so that AoI can install these scripts on your machine. Run it:

    # aoi

and go to the Tools -> Scripts and Plugins Manager menu. Select the Install tab. (Note that if you are behind a firewall you may first have to click on the Setup... button and enter details of your http proxy.) AoI will scan for scripts and plugins (this might look as if it has found nothing as sometimes no files appear in the window; ignore this absence and do the next thing anyway). Click Select all and then on Install selected files. AoI will get all the available plugins and enhancements and install them on your system.

[At the time of writing, there was a bug for installing under XP. The items were not displayed under the install tab. Whilst it looks like they're not there, they are... just click 'select all' then install away - you'll see]

If you want to use AoI to design or modify parts for your RepRap machine to make (and that's the whole point...) then you may care to look at this RepRap page on using it for engineering design.

Eagle

Eagle is the electronics and PCB design software that is used for all the RepRap electronics at Generation 2 (the Arduino electronics) and above. The homepage of Eagle is here.

Eagle is in the Ubuntu distribution:

    # sudo apt-get eagle

Arduino

RepRap uses the Arduino Development Environment for firmware development. Follow that link and the download instructions. If you are using the Sanguino microcontroller you will also need to follow the instructions there to upgrade the Arduino Development Environment to support that too.

!! Congratulations! You now have the entire RepRap project on your computer plus all the software needed to build it, to run it, and to modify it.

Further reading

  • After installing the development environment, you may want to see RepRapHostSoftware for a high-level description of the guts of the software, what they do, and why.