Compiling Kicad on Ubuntu

In my last post, I mentioned that compiling Kicad is something most would not be willing to do.

Most of the scripting in this blog will not work in version 4.0.5 which the most recent as of this writing. I recommend to install either the nightly or build yourself. If you just want the latest verion of Kicad, then you can find nightly builds in the Kicad Downloads Area

Well, this post is about the steps needed to run your own compiled version on Ubuntu 1. These steps worked for me on a freshly installed VirtualBox Ubuntu install.

The scripting support in the latest source based kicad has progressed a bit beyond the released Kicad. There are one or two APIs that have appeared and the scripting window has some IDE’ish features added 2. I do want to make some C++ changes, so I have the need to compile. I was also helpful to step through execution to understand some of the APIs

VirtualBox Ubuntu install

These are my notes from installing Ubuntu VirtualBox.

  • create virtual machine
  • linux – ubuntu 64
  • 4 GB ram
  • virtual disk image
  • file location and size to 32GB

 

virtualbox settings->storage->controller IDE->empty = set to ubuntu-16.04.1-desktop-amd64.iso

start machine

install ubuntu
english
no install updates
erase and install
write the changes to disks – continue
set time zone
set keyboard

put in login details

install

it will want to reboot. do that now.
it will say to remove the install medium. VirtualBox seems to do that automagically

At this point you’ll have a clean install of ubuntu.

Take a snapshot so you’ll have it later.

in VirtualBox manager in the upper right. click snapshots
click on the blue camera and take a snapshot

start the machine again
go the the devices menu at the top-> shared clipboard -> bidirectional
devices menu -> insert guest additions
click run on the popup
give your password

start an xterm

Build Kicad

Based on a list here: https://gist.github.com/ceremcem/4024c0a4a8649e858855 with some additions:

sudo apt-get -y install libwxgtk3.0-0v5 libglew-dev libcairo2-dev libbz2-dev doxygen libssl-dev libboost-dev libboost-thread-dev libboost-context-dev libboost-filesystem-dev libboost-iostreams-dev libboost-locale-dev libboost-program-options-dev swig python-wxgtk3.0* git cmake libwxgtk3.0 libglm-dev libcurl3 libcurl3-dev python-dev

mkdir kicad
cd kicad
mkdir build
mkdir install

git clone -b master https://git.launchpad.net/kicad
cd build
cmake -DCMAKE_BUILD_TYPE=Debug -DwxWidgets_USE_DEBUG=ON -DKICAD_SCRIPTING_WXPYTHON=ON -DKICAD_SCRIPTING=ON -DKICAD_SCRIPTING_MODULES=ON -DCMAKE_INSTALL_PREFIX=`realpath ../install` ../kicad

make
make install

 

If you install into something other than /usr/lib; if you use prefix as is shown above, you’ll need to do this:

export LD_LIBRARY_PATH=`realpath ../install/lib/`

This is for Ubuntu 16.04.1. If these directions stop working, please leave a comment below.


  1. I have basically stopped using the Windows platform. Adobe Lightroom and Autodesk Fusion are the only reasons I bother with it at all. Sorry.

  2. it’s very possible that the IDE stuff is a freebie due to using a more recent Python component.

12 thoughts on “Compiling Kicad on Ubuntu”

  1. Hi!
    I had problems compiling, cmake seems to work but there is an error compiling. I’m using ubuntu:
    gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
    Thank you very much!
    The error is :
    —————————–
    Linking CXX shared module _cvpcb.kiface
    CMakeFiles/cvpcb_kiface.dir/class_components_listbox.cpp.o:(.data.rel.ro._ZTV18COMPONENTS_LISTBOX[_ZTV18COMPONENTS_LISTBOX]+0x770): referencia a `non-virtual thunk to wxGenericListCtrl::GetSizeAvailableForScrollTarget(wxSize const&)’ sin definir
    CMakeFiles/cvpcb_kiface.dir/class_footprints_listbox.cpp.o:(.data.rel.ro._ZTV18FOOTPRINTS_LISTBOX[_ZTV18FOOTPRINTS_LISTBOX]+0x770): referencia a `non-virtual thunk to wxGenericListCtrl::GetSizeAvailableForScrollTarget(wxSize const&)’ sin definir
    CMakeFiles/cvpcb_kiface.dir/class_library_listbox.cpp.o:(.data.rel.ro._ZTV15LIBRARY_LISTBOX[_ZTV15LIBRARY_LISTBOX]+0x770): referencia a `non-virtual thunk to wxGenericListCtrl::GetSizeAvailableForScrollTarget(wxSize const&)’ sin definir
    CMakeFiles/cvpcb_kiface.dir/listboxes.cpp.o:(.data.rel.ro._ZTV18ITEMS_LISTBOX_BASE[_ZTV18ITEMS_LISTBOX_BASE]+0x770): referencia a `non-virtual thunk to wxGenericListCtrl::GetSizeAvailableForScrollTarget(wxSize const&)’ sin definir
    collect2: error: ld returned 1 exit status
    cvpcb/CMakeFiles/cvpcb_kiface.dir/build.make:790: fallo en las instrucciones para el objetivo ‘cvpcb/_cvpcb.kiface’
    make[2]: *** [cvpcb/_cvpcb.kiface] Error 1
    CMakeFiles/Makefile2:851: fallo en las instrucciones para el objetivo ‘cvpcb/CMakeFiles/cvpcb_kiface.dir/all’
    make[1]: *** [cvpcb/CMakeFiles/cvpcb_kiface.dir/all] Error 2
    Makefile:149: fallo en las instrucciones para el objetivo ‘all’
    make: *** [all] Error 2

    1. My guess is that you have missing or incorrect wx library versions installed.

      here are the versions I have based on this command:
      sudo apt-get install -s libwxgtk3.0-0v5 python-wxgtk3.0* libwxgtk3.0

      python-wxgtk3.0 is already the newest version (3.0.2.0+dfsg-1build1).
      python-wxgtk3.0-dev is already the newest version (3.0.2.0+dfsg-1build1).
      libwxgtk3.0-0v5 is already the newest version (3.0.2+dfsg-1.3ubuntu0.1).
      libwxgtk3.0-0v5 set to manually installed.
      libwxgtk3.0-dev is already the newest version (3.0.2+dfsg-1.3ubuntu0.1).

      Let me know if that helps

      1. Thanks for your help, in fact I have installed the same libraries as you. I’m trying to compile again.
        The only difference I found is:
        libwxgtk3.0-dev 3.0.3-1.jessie

        You have installed 3.0.2

        Could be this the problem?

        1. so I just recloned and rebuilt. All’s fine.

          when I build make VERBOSE=1, I get this for cbpcb.kiface:
          [ 52%] Linking CXX shared module _cvpcb.kiface
          cd /bubba/electronicsDS/kicad/development/kicad/build/cvpcb && /usr/bin/cmake -E cmake_link_script CMakeFiles/cvpcb_kiface.dir/link.txt –verbose=1
          /usr/bin/c++ -fPIC -Wall -Wsuggest-override -Wno-unused-local-typedefs -Wno-strict-aliasing -fopenmp -pthread -Wshadow -g3 -ggdb3 -DDEBUG -Wno-deprecated-declarations -Wl,–no-undefined -Wl,-Bsymbolic -shared -o _cvpcb.kiface CMakeFiles/cvpcb_kiface.dir/cvpcb.cpp.o CMakeFiles/cvpcb_kiface.dir/__/common/base_units.cpp.o CMakeFiles/cvpcb_kiface.dir/__/pcbnew/board_items_to_polygon_shape_transform.cpp.o CMakeFiles/cvpcb_kiface.dir/__/pcbnew/class_drc_item.cpp.o CMakeFiles/cvpcb_kiface.dir/autosel.cpp.o CMakeFiles/cvpcb_kiface.dir/cfg.cpp.o CMakeFiles/cvpcb_kiface.dir/class_components_listbox.cpp.o CMakeFiles/cvpcb_kiface.dir/class_DisplayFootprintsFrame.cpp.o CMakeFiles/cvpcb_kiface.dir/class_footprints_listbox.cpp.o CMakeFiles/cvpcb_kiface.dir/class_library_listbox.cpp.o CMakeFiles/cvpcb_kiface.dir/cvpcb_mainframe.cpp.o CMakeFiles/cvpcb_kiface.dir/listboxes.cpp.o CMakeFiles/cvpcb_kiface.dir/menubar.cpp.o CMakeFiles/cvpcb_kiface.dir/readwrite_dlgs.cpp.o CMakeFiles/cvpcb_kiface.dir/tool_cvpcb.cpp.o CMakeFiles/cvpcb_kiface.dir/dialogs/fp_conflict_assignment_selector_base.cpp.o CMakeFiles/cvpcb_kiface.dir/dialogs/fp_conflict_assignment_selector.cpp.o CMakeFiles/cvpcb_kiface.dir/dialogs/dialog_display_options.cpp.o CMakeFiles/cvpcb_kiface.dir/dialogs/dialog_display_options_base.cpp.o CMakeFiles/cvpcb_kiface.dir/dialogs/dialog_config_equfiles_base.cpp.o CMakeFiles/cvpcb_kiface.dir/dialogs/dialog_config_equfiles.cpp.o CMakeFiles/cvpcb_kiface.dir/__/pcbnew/dialogs/dialog_fp_lib_table.cpp.o CMakeFiles/cvpcb_kiface.dir/__/pcbnew/dialogs/dialog_fp_lib_table_base.cpp.o CMakeFiles/cvpcb_kiface.dir/__/pcbnew/dialogs/dialog_fp_plugin_options.cpp.o CMakeFiles/cvpcb_kiface.dir/__/pcbnew/dialogs/dialog_fp_plugin_options_base.cpp.o CMakeFiles/cvpcb_kiface.dir/__/pcbnew/dialogs/wizard_add_fplib_base.cpp.o CMakeFiles/cvpcb_kiface.dir/__/pcbnew/dialogs/wizard_add_fplib.cpp.o ../3d-viewer/lib3d-viewer.a ../common/libpcbcommon.a ../pcbnew/pcad2kicadpcb_plugin/libpcad2kicadpcb.a ../common/libcommon.a ../bitmaps_png/libbitmaps.a ../polygon/libpolygon.a ../common/libgal.a -L/usr/lib/x86_64-linux-gnu -pthread -lwx_gtk2u_gl-3.0 -lwx_gtk2u_aui-3.0 -lwx_gtk2u_adv-3.0 -lwx_gtk2u_html-3.0 -lwx_gtk2u_core-3.0 -lwx_baseu_net-3.0 -lwx_baseu-3.0 -lwx_baseu_xml-3.0 -lwx_gtk2u_stc-3.0 ../pcbnew/github/libgithub_plugin.a -lrt ../3d-viewer/lib3d-viewer.a ../3d-viewer/3d_cache/sg/libkicad_3dsg.so.2.0.0 -L/usr/lib/x86_64-linux-gnu -pthread -lwx_gtk2u_gl-3.0 -lwx_gtk2u_aui-3.0 -lwx_gtk2u_adv-3.0 -lwx_gtk2u_html-3.0 -lwx_gtk2u_core-3.0 -lwx_baseu_net-3.0 -lwx_baseu-3.0 -lwx_baseu_xml-3.0 -lwx_gtk2u_stc-3.0 ../common/libcommon.a ../common/libgal.a -lGLEW -lcairo -lpixman-1 -lGLU -lGL -lcurl -lssl -lcrypto -Wl,-rpath,/bubba/electronicsDS/kicad/development/kicad/build/3d-viewer/3d_cache/sg:

          searching for the symbol GetSizeAvailable, I find this:
          nm -D /usr/lib/x86_64-linux-gnu/libwx_gtk2u_adv-3.0.so | grep GetSizeAvailableForScrollTarget | c++filt
          U wxGenericListCtrl::GetSizeAvailableForScrollTarget(wxSize const&)
          00000000000e1fc0 T wxGrid::GetSizeAvailableForScrollTarget(wxSize const&)
          00000000000e1fe0 T non-virtual thunk to wxGrid::GetSizeAvailableForScrollTarget(wxSize const&)
          U non-virtual thunk to wxGenericListCtrl::GetSizeAvailableForScrollTarget(wxSize const&)

          and
          nm -D /usr/lib/x86_64-linux-gnu/libwx_gtk2u_core-3.0.so | grep GetSizeAvailableForScrollTarget | c++filt
          00000000002b3f50 T wxGenericListCtrl::GetSizeAvailableForScrollTarget(wxSize const&)
          00000000002b3fc0 T non-virtual thunk to wxGenericListCtrl::GetSizeAvailableForScrollTarget(wxSize const&)

          when I look in /usr/include/wx-3.0/wx/version.h I see this:

          #define wxMAJOR_VERSION 3
          #define wxMINOR_VERSION 0
          #define wxRELEASE_NUMBER 2
          #define wxSUBRELEASE_NUMBER 0
          #define wxVERSION_STRING wxT(“wxWidgets 3.0.2”)

          I don’t know what a non-virtual thunk is, but perhaps this information will get you closer.

          1. Yesterday I tried to compile using wx 3.1.0, but I got the same error. I don’t know what happens with this library. I will compile with VERBOSE and try to look for the function that crash, maybe something is missing.

            Thanks for your help, as soon as I try I’ll inform you

            Best Regards

          2. Hi !

            I checked the libraries and I get this:
            ————–
            nm -D /usr/lib/x86_64-linux-gnu/libwx_gtk2u_adv-3.0.so.0 | grep GetSizeAvailableForScrollTarget | c++filt
            U wxGenericListCtrl::GetSizeAvailableForScrollTarget(wxSize const&)
            00000000000e1fc0 T wxGrid::GetSizeAvailableForScrollTarget(wxSize const&)
            00000000000e1fe0 T non-virtual thunk to wxGrid::GetSizeAvailableForScrollTarget(wxSize const&)
            U non-virtual thunk to wxGenericListCtrl::GetSizeAvailableForScrollTarget(wxSize const&)
            ———–
            It is different as yours

          3. Hi !

            Thanks to your log I found that I had installed a different version of libwxgtk. I had configured in sources.list the propietary repo from wxWidgets. I remove all the libraries, remove the line in the repo and download the official libraries from ubuntu.
            After that I could compiled !!

            Thank you so much for your help !! Your logs gave me the clue I need 😉

  2. I’m glad it worked out for you!

    I’ll make a further recommendation that I maybe should have mentioned before….

    I find it helpful to have an additional ubuntu install under virtualbox. It makes it easy to have a fresh/clean install. After I try something, I can easily revert with the snapshot feature.

    For you,… now comes the fun of trying to understand the kicad codebase. It’s mostly good, but the organization could use some work.

  3. Thanks for your documents!

    I have a trouble on pcbnew to use OpenGL view mode and cairo view mode
    using Ubuntu 16.04.2 as a VBox on Windows 10.

    Do you have some idea to use OpenGL view?
    You could use those view modes?

  4. I found that I also had to run
    sudo apt-get install libboost-all-dev
    on a clean ubuntu install to make cmake happy. Hope this saves someone else the time I spent figuring it out!

Leave a Reply

Your email address will not be published. Required fields are marked *