== These build-from-source instructions are terribly out of date, use the official documents at http://linuxcnc.org/docs/2.8/html/code/building-linuxcnc.html |
These build-from-source instructions are terribly out of date, use the official documents at http://linuxcnc.org/docs/master/html/code/building-linuxcnc.html |
THIS PAGE HAS BEEN PARTIALLY EDITED TO REFLECT THE AGREEMENT TO REBRAND EMC2 AS LINUXCNC AND THE RELEASE OF LINUXCNC 2.5.If you are still interested in earlier versions, you may find the superseded Installing EMC2 page of interest.
You can follow the instructions beginning with Step 3 on [Basic Installation] which is a page on the companion website. (Note that Firefox downloads the script to your ~/Downloads directory, not to the Desktop.) If you use this method, you don't need to read the rest of this page; just start Using LinuxCNC.
You can follow the instructions beginning with Step 3 on [Basic Installation] which is a page on the companion website. (Note that Firefox downloads the script to your ~/Downloads directory, not to the Desktop.) If you use this method, you don't need to read the rest of this page; just start Using LinuxCNC.
A LinuxCNC Simulator is convenient for exploring LinuxCNC, playing with G-Code onscreen, and developing and testing non-realtime user-space components, all on a Ubuntu system that does not have the RTAI kernel extensions installed. Go to LinuxCNC Pure Simulator for instructions on installing precompiled LinuxCNC simulator packages to existing Ubuntu systems.
If you want to compile additional components for LinuxCNC, you can stop reading this page now! You do not have to recompile LinuxCNC just to add components. For instructions on adding components, read [How to compile and install a component].
Even with your additional components, the instructions above give you a standard, released version of LinuxCNC, which is what most users have. It is the version with the best support from manuals, the mailing list, and the IRC channel.
These instructions make extensive use of the Linux command-line interface in which commands are typed into a Terminal. If you are not familiar with this mode of operation, you should take time to learn it.
If you wish to build LinuxCNC from source, follow the steps given below. Indented text that looks
like the text on this lineis text that you type into the terminal or editor window.
First enable the universe repository (to find needed packages not in the Canonical repository ) if it isn't already. This can be done in the Ubuntu GUI by clicking System>Administration>Software Sources from the menu bar and ticking "Community-maintained Open Source software (universe)" in the Ubuntu Software tab if it isn't already. The same tab can be reached by clicking Settings>Repositories in the menu bar of the Synaptic Package Manager (which can be started from the command line by typing "sudo synaptic".)
You need to add the LinuxCNC repository to the apt sources list if it hasn't been already. This also can be done in the Ubuntu GUI by clicking System>Administration>Software Sources from the menu bar or clicking Settings>Repositories in the menu bar of the Synaptic Package Manager. In the list presented in the Other Software tab, look for the following entries to be present and ticked
-for Ubuntu 10.04 (Lucid Lynx)
http://www.linuxcnc.org/ lucid base linuxcnc2.5 http://www.linuxcnc.org/ lucid base linuxcnc2.5 (Source Code)
-for Ubuntu 8.04 (Hardy Heron)
http://www.linuxcnc.org/ hardy base linuxcnc2.5 http://www.linuxcnc.org/ hardy base linuxcnc2.5 (Source Code)
If these entries are not present, then use the +Add... function to add the following two lines one at a time
-for Ubuntu 10.04 (Lucid Lynx)
deb http://www.linuxcnc.org/ lucid base linuxcnc2.5 deb-src http://www.linuxcnc.org/ lucid base linuxcnc2.5
-for Ubuntu 8.04 (Hardy Heron)
deb http://www.linuxcnc.org/ hardy base linuxcnc2.5 deb-src http://www.linuxcnc.org/ hardy base linuxcnc2.5
<<TBA - how to add, using the Ubuntu GUI, the public key that corresponds to the GPG key used to digitally sign the LinuxCNC source packages.>>
As an alternative to working in the Ubuntu GUI, do this (the following will also install the precompiled LinuxCNC):
-for Ubuntu 10.04 (Lucid Lynx)
wget http://www.linuxcnc.org/install-scripts/lucid/linuxcnc-install.sh chmod 755 linuxcnc-install.sh ./linuxcnc-install.sh
-for Ubuntu 8.04 (Hardy Heron)
wget http://www.linuxcnc.org/install-scripts/hardy/linuxcnc-install.sh chmod 755 linuxcnc-install.sh ./linuxcnc-install.sh
Ubuntu will ask you for your root password in order for the linuxcnc-install.sh script to modify the apt sources list, to add the public key, and to install the new required packages. At this point, you must reboot and select the rtai kernel from the grub bootloader menu. Then, continue with the next step.
sudo apt-get install libpth-dev sudo apt-get build-dep linuxcnc
This operation will download and install more than 500Mb of archives to a stock Ubuntu system---15 minutes in this writer's case---time enough to make a pot of coffee, catch up on email, or whatever; don't just sit and watch the screen-crawl.
Note: It would seem to this writer that the build-dep operation should catch the need for the libpth-dev library but at the moment (20120819) it seems to not do so.
If you get an error like this one:
Package libpth-dev is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source E: Package libpth-dev has no installation candidate
then you have not configured the apt sources list correctly and the compilation step will fail.
First, follow the steps above to get the extra packages needed to compile LinuxCNC.
If it is not already present, you also will need to install the git program:
sudo apt-get install git-core gitk git-gui
Once you have installed git, you will use it to create a local copy (a "clone") of the LinuxCNC source-files project from our git server
git clone git://git.linuxcnc.org/git/linuxcnc.git linuxcnc-devThis puts the project in the directory 'linuxcnc-dev'. To put the local copy of the project in a different location, just change the last argument of the 'git clone' command. (Note: many discussants assume this directory is still named 'emc2-dev'. It doesn't matter what the name is, just be consistent in your work.) Git will download about 55MB of data and it takes a few minutes (5 minutes in this writer's case) to complete. You should only have to do this once.
The commands below generally assume you have now changed to the directory created by the git clone command.
By default, you will get files from "master", which is the name for the branch where new feature development takes place. At the current time (20120820) this is LinuxCNC 2.6.0~pre. If you want to track another branch, say the current, stable, v2.5 branch,
cd linuxcnc-dev git branch --track v2.5_branch origin/v2.5_branch git checkout v2.5_branch(For branches before v2.5_branch, substitute an underscore for a full stop, e.g., v2_4_branch)
To return to the master branch
git checkout master
To get a particular version of LinuxCNC, use
git checkout vX.Y.ZFor instance, to get released version 2.5.0, use
git checkout v2.5.0
Note that if you use a tag for a specific release, you will never get any updates since the tag specifies a particular snapshot of the files. Using a branch tag, such as "v2.4_branch", will continue to get changes as long as that branch is being developed.
Git has more instructions, such as how to update your version of emc2 after other developers have made improvements.
git pullIf you have made changes locally, then before doing this step you must "git commit" or "git stash" them. For more information, see Git.
If you do not have a recent LinuxCNC install from CD or net on your machine, or if the installation requirements have gotten ahead of this wiki page, you might be missing some build dependencies (packages needed for a compile, or documentation build). These make the next step (build) fail during the './configure ..' run.
If this happens, or even just to forestall it happening, proceed as follows in the directory created by the git clone command:
cd debian ./configure -a (if installing simulator use "./configure sim" instead) cd .. dpkg-checkbuilddeps
Then "apt-get install" each of the missing build dependencies, and your configure should work (the configure script in the ./src directory this time, not in the ./debian directory). If installing simulator - don't apt-get install the rtai-modules-x.x.... package.
If you're building the current master (2.6pre) you need an additional dependency
sudo apt-get install libboost-python-dev
I have gotten this error a couple times
"configure: error: Tcl and Tk versions must be the same,...."
try adding:
--with-tkConfig=/usr/lib/tk8.5/tkConfig.sh --with-tclConfig=/usr/lib/tcl8.5/tclConfig.sh
to the ./configure command
If you have already installed LinuxCNC from the Live-CD do not use --prefix/make install. make with no options will default to the 'run in place' method.
Run these commands in the directory created by git above (e.g., linuxcnc-dev):
cd src ./autogen.sh ./configure make make install-menus sudo make setuid
the make command may take several minutes to complete.
Run these commands in the directory created by git above:
cd src ./autogen.sh ./configure --enable-simulator make make install-menus
the make command may take several minutes to complete.
Offline machines can get autogen & build-essential packages using Synaptic and a thumb drive.
begin ------------------offline machine gets autogen and build-essential pks ------------------- The offline machine wont have autogen nor build-essentials to begin with, so what to do? Use a thumb drive (or similar) and Syanaptic to create 'wget' scripts. Just grabbing files from internet does not work well, you need to accommodate the dependencies for the files you grab. Synaptic can review your system state and build a list of files based on what that state is. The state of your package information can go stale, and you cannot update that information while offline, but the following sequence helped me get the files needed to build emc for an offline system. I used a thumb drive and took advantage of a feature in Synaptic 'File|Generate package download list'. This command creates a shell script file that uses wget for the <b> already selected files</b>. ( the 'already selected files' might be autogen and build-essential for example ). Once this script is generated, it can be placed onto the removable media, taken to a machine that <b>is</b> online, and the packages retrieved to the removable media. Then, the media can be moved back to the offline system, and when running Synaptic again, choose 'Files | Add downloaded packages'. For most folks the default action of installing all files will be whats wanted. (this may not be what you want to do, and you can cancel if thats true, the files will be placed in the system pkg cache for later use ). During the on-line downloads, the wget program may error with a message saying a file is not found. In my case it happened because a file version was no longer available due to a stale package information database. For example, simply changing python-gnome2-extras_2.19.1-0ubuntu7.1_i386.deb to python-gnome2-extras_2.19.1-0ubuntu7.2_i386.deb in the script fixed this for me. So a few stabs at the wget script should get all the files you need for the offline machine. hth tom3p end ------------------offline machine gets autogen and build-essential pks -------------------
. ./scripts/rip-environment linuxcncand choose a configuration file from the list offered in the Configuration Selector, or specify one on the command line:
linuxcnc <path to configuration ini file>for example
linuxcnc ~/linuxcnc/configs/sim/axis/axis.iniIf you get an error like
Realtime system did not loadthen stop the rtai with
halcmd unloadrt all halcmd stopthen start again. Sometimes the first load will clear up an issue...
If you compile for realtime in a directory tree (git checkout), and then later reconfigure for --enable-simulator, you must do
make cleanto get rid of the realtime object files. The same applies when switching from simulation to realtime. This is because "make" doesn't know that you've changed modes. It only sees that the object files are newer than the source, and thinks they don't need to be recompiled.
Another potential problem when switching from realtime to simulation is environment variables. The command
. scripts/rip-environmentsets some environment variables in your shell to point to various parts of the run-in-place code. Some of those variables are different for realtime vs. simulation. If you switch modes, you should close the shell you were using, open a new one, and run
. scripts/rip-environmentbefore starting LinuxCNC from that shell.
The same issues can arise if you have multiple git checkouts and switch between them using the same shell. If you are switching between versions or checkouts, it is best to use one shell for each one.
$ sudo apt-get install libpth-dev tcl8.5-dev tk8.5-dev bwidget libxaw7-dev libreadline5-dev python-dev libglu1-mesa-dev libxinerama-dev autoconf python-tk libglib2.0-dev libxft-dev gettext
$ sudo apt-get install python-gnome2 python-glade2 python-numpy python-imaging python-xlib python-gtkglext1 python-configobj python-gtksourceview2
If configured to build for the running kernel:
$ debian/configure -r $ dpkg-checkbuilddeps
If configured to build without a realtime kernel (simulator mode):
$ debian/configure sim $ dpkg-checkbuilddeps
The dpkg-checkbuilddeps command should produce no output.
Run debian/configure without any options for usage help.
Released versions of emc2.2.x and older are available from the [SourceForge download area].
The current kernel source package can be installed like so:
apt-get source linux-image-2.6.32-122-rtai
NOTE: the material in this section is getting stale and should taken as being merely indicative. For example, it references older versions of the kernel and rtai patches than are used in recent releases of LinuxCNC.
Follow the instructions at RtaiSteps to build a real-time kernel for your particular Linux distribution. After that, you'll have to figure out the names of the extra packages needed to install and run emc2. As an aid, these are the packages required by the emc2 ubuntu package:
Depends: libatk1.0-0 (>= 1.9.0), libc6 (>= 2.3.4-1), libcairo2 (>= 1.0.2-2), libfontconfig1 (>= 2.3.0), libgcc1 (>= 1:4.0.2), libgl1-mesa | libgl1, libglib2.0-0 (>= 2.10.0), libglu1-mesa | libglu1, libgtk2.0-0 (>= 2.8.0), libice6, libpango1.0-0 (>= 1.12.3), libreadline5 (>= 5.1), libsm6, libstdc++6 (>= 4.0.2-4), libx11-6, libxaw7, libxcursor1 (>> 1.1.2), libxext6, libxfixes3, libxi6, libxinerama1, libxmu6, libxrandr2, libxrender1, libxt6, tcl8.4 (>= 8.4.5), tk8.4 (>= 8.4.5), linux-image-2.6.15-magma, rtai-modules-2.6.15-magma, tcl8.4, tk8.4, libreadline5, python2.4-numarray, python2.4-imaging, python2.4-imaging-tk, python (>= 2.4), python (<< 2.5), emc2, python (<< 2.5), python (>= 2.4), bwidget (>= 1.7), bwidget (<< 1.8), python2.4-tk, python2.4-xml
Build-Depends: debhelper (>> 4.0.0), linux-image-2.6.15-magma, rtai-modules-2.6.15-magma, linux-headers-2.6.15-magma, gcc-4.0, g++, make, libc6-dev, tcl8.4-dev, tk8.4-dev, libgtk2.0-dev, pciutils-dev, libncurses-dev, gettext, libxaw7-dev, libreadline5-dev, lyx-qt, python, tetex-bin, latex2html, python2.4-dev, libglu1-mesa-dev, libgl1-mesa-dev, libgnomeprint2.2-dev, groff, bwidget, tetex-extra
To get your nvidia graphics card working, edit the xorg.conf file in the /etc/X11 directory. At about line 66, in the section "Device", find a line that looks like: Driver "nvidia" , replace nvidia with "nv" or "vesa" (try "nv" first). If you have previously tried to use the nvidia driver, you must remove nvidia-related packages by issuing the following command from a terminal:
sudo apt-get --purge remove nvidia-glx nvidia-settings nvidia-kernel-common
There is at least one report that even when using the open source 'nv' driver, the latency test will show failures.
export SRCPATH=<path to your emc build>
#remove the python modules cd /usr/lib/python2.4/site-packages/ ls $SRCPATH/lib/python | xargs sudo rm -r
sudo rm -r /usr/local/etc/emc2/ /usr/realtime*/modules/emc2/ /usr/local/share/emc/ /usr/local/share/axis/ sudo rm /etc/init.d/realtime
cd /usr/local/bin/ ls $SRCPATH/bin/ | xargs sudo rm sudo rm emc emcmkdesktop halrun
cd /usr/local/lib ls $SRCPATH/lib/ | xargs sudo rm
You may need to apt-get remove --purge emc2 if you installed it "over" the existing install, otherwise you will get the wrong /etc/init.d/realtime script (or no script!)
One way to avoid this predicament is instead of "make install", to use the "checkinstall" program, which monitors the install process and creates a package for you that can easily be uninstalled.
Sometimes, development branches or fixes are announced on the mailing list or IRC by pointing to a branch in another git repository, for instance "can you try http://git.mah.priv.at/gitweb/emc2-dev.git/shortlog/refs/heads/g84-dev ?"
To try out such a branch, you need to add the remote repository and setup to track that branch. It's useful to avoid importing other branches which might happen to exist in this repository to save disk space and time, and avoid cluttering your repository with remote branches you're not interested in. To do so, proceed as follows:
$ git remote add mah git://git.mah.priv.at/emc2-dev.git $ git config remote.mah.fetch +refs/heads/g84-dev:refs/remotes/mah/g84-dev $ git fetch mah $ git branch --track g84-dev mah/g84-dev $ git checkout g84-dev
Sometimes, more commits are added to such a remote branch. To update your local branch, use this:
$ git checkout g84-dev $ git pull