I found myself faced with the need to install KiCAD from source after upgrading my laptop to Ubuntu 18.04 and installing KiCAD 4.07 which is the stable version from the Ubuntu repositories but it had graphics issues. The cursor painting was was leaving a trail on eeschema making it unusable. I wanted to install from source as a last resort after trying every intel graphics and X11 hack I could find to no avail, if there was even the slightest chance to fix the bug it would include at least building the right packages from the source.
installing the dependencies
There are some dependencies that have been outlined on the github page, check and install for your distro. This list may not be exhaustive here as I may have had some of them already installed.
sudo apt install libreadline-dev libboost-all-dev liboce-foundation-dev liboce-ocaf-dev libssl-dev libbz2-dev doxygen
I also built ngspice from source following my earlier tutorial in which I fixed a bug. libngspice doesn’t really install well from Ubuntu repositories either.
Get the Source
Get the source code by clicking the KiCAD launchpad download link. This gets you the source for version 4.0.7. save the file somewhere in your computer [I always use the directory ~/src] and extract the .tar.xz file, cd into the folder.
create a build directory:
mkdir build && cd build
We need to Install without scripting to avoid wxpython3.0 wxpython2.8 wars: I couldn’t install wxpython2.8 in Ubuntu 18.04 .
You have to initialize bzr first or the build command will complain. I have no idea what that is, I only used git but I think it’s some version control tool like git. Anyway the command is:
bzr whoami "First Last<email@example.com>"
The option for switching off scripting is: T-DKICAD_SCRIPTING_WXPYTHON=OFF. Run cmake to generate the makefiles.
cmake -DKICAD_SCRIPTING_WXPYTHON=OFF ../
make -j5 followed by
sudo make install, I realized it builds everything twice, takes long. If I were you I would just run:
sudo make install
Sure thing after this, KiCAD Eeschema runs without cursor trailing problems at all. Checking the version information shows that it compiled with WxWidgets 3.0.4, amazing!
We are not done yet, there are no libraries installed. We need to get out of the KiCAD repository and clone the kicad-library repository from github. Remember we are now inside the build directory, inside the repository.
cd ../../ git clone https://github.com/KiCad/kicad-library.git
then change directories into the kicad-library repository and configure it, then install. The libraries need not be built.
cd kicad-library && mkdir build && cd build
Run Cmake to configure the library repository
cmake ../ -- The C compiler identification is GNU 7.3.0 -- The CXX compiler identification is GNU 7.3.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done -- Generating done -- Build files have been written to: /home/myusername/src/kicad-library/build
sudo make install
Paths and Default Library List
The default Kicad Paths for libraries are under /usr/share/kicad, but when installing from source, the default installation location is /usr/local/share/kicad. There is need to change those paths. Open Kicad, go to Preferences->Configure Paths and click on each of the paths, change accordingly and save.
After this, you can now create a new project and all should be well. Except when you get that annoying Eeschema pop-up error message about some libraries not being found.
Well, it turns out that Linux is case sensitive and over time, the github repo has been updated with library name changes, especially in terms of case-sensitivity…
We can change the source code since we have it and rebuild, but that would be an overkill. This is just a library configuration problem. The way KiCad is set up is such that every new project created is usually loaded with the default configuration. The default configuration file is usually in /usr/share/kicad/template/kicad.pro or in /usr/local/share/kicad.template/kicad.pro if you installed from source like we did. All we need to do is edit this file and put the right list of library names. But how do we do that? Very simple. We create a test project somewhere in the computer, you know like
~/src/KicadTest/test.pro. Then we open the schematic file in Eeschema by double-clicking on it. Then cancel the error message that pops up. Then open Preferences->Component Libraries. Click on any one of the pre-loaded libraries and then press CTRL+A to select all of them. Hit the remove button to exclude all of them. Then click the add button, it will pop-up a window with the default installation location for the libraries. Select all of the libraries and add them. Save the schematic, the project and quit Kicad. Now open the project file you just saved in gedit, that is
~/src/KicadTest/test.pro. It will have a list of all the libraries you added after a few lines like so:
[eeschema/libraries] LibName1=ac-dc LibName2=adc-dac LibName3=Altera LibName4=analog_devices LibName5=analog_switches LibName6=atmel LibName7=audio LibName8=Battery_Management LibName9=bbd LibName10=Bosch LibName11=brooktre LibName12=Connector LibName13=contrib LibName14=cypress LibName15=dc-dc LibName16=Decawave LibName17=device LibName18=digital-audio LibName19=Diode LibName20=Display...
All we have to do is borrow this list of libraries and paste it into the default kicad.pro file as a configuration.
Open the default file in gedit with super user permissions:
sudo gedit /usr/local/share/kicad/template/kicad.pro
delete the list of libraries after the line
[eeschema/libraries] upto the end and copy paste the same list from the test project. Save and close the file.
Now every time you create a new project it will have all those libraries loaded by default, with correct names. If you are not happy with loading all those libraries in KiCad by default because may be your computer sucks, you can edit that configuration file as required. It pays to know the ins and outs of how an application is set up :-).
Enjoy a working KiCad stable version in the latest version of Ubuntu Linux. I am sure the instructions for Arch and other distributions are very similar. Cheers.