Building kicad on Linux Mint 19.1 (was: on osx 10.14)

I’m wondering what’s needed to build kicad on osx? I’m trying to use a fresh clone of https://github.com/KiCad/kicad-mac-builder

The full build output is in http://www.rockgarden.net/download/kicad/screenlog.0.gz

It dies with what seems like a missing XCode 10.13 SDK OpenGL framework. (I’ve installed the 10.13 SDKs on my 10.14 system via XCode.)

I installed/upgraded the list of brew parts listed in the builder repo’s top level readme.md.

Scanning dependencies of target s3d_plugin_idf
[ 86%] Building CXX object plugins/3d/idf/CMakeFiles/s3d_plugin_idf.dir/s3d_plugin_idf.cpp.o
[ 86%] Building CXX object plugins/3d/idf/CMakeFiles/s3d_plugin_idf.dir///__/utils/idftools/vrml_layer.cpp.o
[ 86%] Linking CXX shared module …/…/…/kicad/kicad.app/Contents/PlugIns/3d/libs3d_plugin_idf.so
[ 86%] Built target s3d_plugin_idf
[ 88%] Built target s3d_plugin_vrml
make[5]: *** No rule to make target /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/OpenGL.framework', needed by kicad/kicad.app/Contents/PlugIns/3d/libs3d_plugin_oce.so’. Stop.
make[4]: *** [plugins/3d/oce/CMakeFiles/s3d_plugin_oce.dir/all] Error 2
make[3]: *** [all] Error 2
make[2]: *** [kicad/src/kicad-stamp/kicad-build] Error 2
make[1]: *** [CMakeFiles/kicad.dir/all] Error 2
make: *** [all] Error 2
Error while running make after rebuilding with a single job. Please report this issue if you cannot fix it after reading the README.
build.py argument summary:
build_type: Debug
docs_tarball_url: http://docs.kicad.org/kicad-doc-HEAD.tar.gz
extra_version: None
footprints_ref: origin/master
jobs: 1
kicad_ref: origin/master
macos_min_version: 10.14
packages3d_ref: origin/master
release: False
release_name: None
retry_failed_build: True
symbols_ref: origin/master
target: []
templates_ref: origin/master
translations_ref: origin/master
Traceback (most recent call last):
File “./build.py”, line 223, in
main()
File “./build.py”, line 219, in main
build(parsed_args)
File “./build.py”, line 191, in build
subprocess.check_call(make_command, env=dict(os.environ, PATH=new_path))
File “/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py”, line 190, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command ‘[‘make’, ‘-j1’]’ returned non-zero exit status 2

I have no experience in building on mac so can’t help you here. But to answer your question from the other thread, which platform is easiest to build on: probably linux. Windows comes close second with the win builder scripts.

Turns out building on 10.14 isn’t supported.

I’ll give Linux a shot.

Can’t even build a patched wxWidgets 3.0.2 on Linux. So not even close there.

Okay, got past that - it had some ancient dependencies. Let’s see how this works out.

I can’t seem to figure out how to tell CMake where to locate wxWidgets… I have a patched wxWidgets-3.0.2 installed in /usr/local. It finds everything else fine it seems, including the ngspice libraries I built. Any ideas?

$ cd build/debug
$ rm -f CMakeCache.txt
$ cmake -DCMAKE_BUILD_TYPE=Debug -DwxWidgets_INCLUDE_DIRS=/usr/local/include/wx-3.0 -DwxWidgets_LIBRARIES=/usr/local/lib -DNGSPICE_INCLUDE_DIR=/usr/local/include/ngspice -DCMAKE_INSTALL_PREFIX=/home/bson/kicad-install …/…/
– The C compiler identification is GNU 7.4.0
– The CXX compiler identification is GNU 7.4.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
– KiCad install dir: </home/bson/kicad-install>
– Looking for malloc.h
– Looking for malloc.h - found
– Looking for iso646.h
– Looking for iso646.h - found
– Looking for stdint.h
– Looking for stdint.h - found
– Looking for strcasecmp
– Looking for strcasecmp - found
– Looking for strncasecmp
– Looking for strncasecmp - found
– Looking for strtok_r
– Looking for strtok_r - found
– Looking for malloc
– Looking for malloc - found
– Looking for math.h
– Looking for math.h - found
– Looking for C++ include cmath
– Looking for C++ include cmath - found
– Looking for asinh
– Looking for asinh - found
– Looking for acosh
– Looking for acosh - found
– Looking for atanh
– Looking for atanh - found
– Performing Test HAVE_CMATH_ISINF
– Performing Test HAVE_CMATH_ISINF - Success
– Looking for clock_gettime in rt
– Looking for clock_gettime in rt - found
– Looking for gettimeofday
– Looking for gettimeofday - found
– Looking for getc_unlocked
– Looking for getc_unlocked - found
– Performing Test COMPILER_SUPPORTS_WSUGGEST_OVERRIDE
– Performing Test COMPILER_SUPPORTS_WSUGGEST_OVERRIDE - Success
– Performing Test COMPILER_SUPPORTS_WVLA
– Performing Test COMPILER_SUPPORTS_WVLA - Success
– Performing Test COMPILER_SUPPORTS_WSHADOW
– Performing Test COMPILER_SUPPORTS_WSHADOW - Success
– Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so
– Found GLEW: /usr/include
– Check for installed GLEW – found
– Found GLM: /usr/include (found suitable version “0.9.9.0”, minimum required is “0.9.5.1”)
– Found CURL: /usr/lib/x86_64-linux-gnu/libcurl.so (found version “7.58.0”)
– Found PkgConfig: /usr/bin/pkg-config (found version “0.29.1”)
– Checking for module ‘cairo’
– Found cairo, version 1.15.10
– Found Cairo: /usr/lib/x86_64-linux-gnu/libcairo.so (found suitable version “1.15.10”, minimum required is “1.12”)
– Checking for module ‘pixman-1’
– Found pixman-1, version 0.34.0
– Found Pixman: /usr/lib/x86_64-linux-gnu/libpixman-1.so (found suitable version “0.34.0”, minimum required is “0.30”)
– Boost version: 1.65.1
– Found ngspice: /usr/local/include/ngspice
– Found SWIG: /usr/bin/swig3.0 (found suitable version “3.0.12”, minimum required is “3.0”)
– Found PythonInterp: /usr/bin/python2 (found suitable version “2.7.15”, minimum required is “2.6”)
– Check for installed Python Interpreter – found
– Python module install path: lib/python2.7/dist-packages
– Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython2.7.so (found suitable version “2.7.15+”, minimum required is “2.6”)
– Found wxPython 3.0.2.0/gtk3 (wxWidgets 3.0.2.0)
CMake Error at /usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find wxWidgets (missing: wxWidgets_LIBRARIES
wxWidgets_INCLUDE_DIRS) (Required is at least version “3.0.2.0”)
Call Stack (most recent call first):
/usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
CMakeModules/FindwxWidgets.cmake:944 (find_package_handle_standard_args)
CMakeLists.txt:763 (find_package)

– Configuring incomplete, errors occurred!
See also “/home/bson/kicad/build/debug/CMakeFiles/CMakeOutput.log”.
$ ls /usr/local/lib/libwx*
/usr/local/lib/libwx_baseu-3.0.so /usr/local/lib/libwx_gtk2u_adv-3.0.so /usr/local/lib/libwx_gtk2u_gl-3.0.so /usr/local/lib/libwx_gtk2u_qa-3.0.so /usr/local/lib/libwx_gtk2u_stc-3.0.so
/usr/local/lib/libwx_baseu-3.0.so.0 /usr/local/lib/libwx_gtk2u_adv-3.0.so.0 /usr/local/lib/libwx_gtk2u_gl-3.0.so.0 /usr/local/lib/libwx_gtk2u_qa-3.0.so.0 /usr/local/lib/libwx_gtk2u_stc-3.0.so.0
/usr/local/lib/libwx_baseu-3.0.so.0.2.0 /usr/local/lib/libwx_gtk2u_adv-3.0.so.0.2.0 /usr/local/lib/libwx_gtk2u_gl-3.0.so.0.2.0 /usr/local/lib/libwx_gtk2u_qa-3.0.so.0.2.0 /usr/local/lib/libwx_gtk2u_stc-3.0.so.0.2.0
/usr/local/lib/libwx_baseu_net-3.0.so /usr/local/lib/libwx_gtk2u_aui-3.0.so /usr/local/lib/libwx_gtk2u_html-3.0.so /usr/local/lib/libwx_gtk2u_ribbon-3.0.so /usr/local/lib/libwx_gtk2u_xrc-3.0.so
/usr/local/lib/libwx_baseu_net-3.0.so.0 /usr/local/lib/libwx_gtk2u_aui-3.0.so.0 /usr/local/lib/libwx_gtk2u_html-3.0.so.0 /usr/local/lib/libwx_gtk2u_ribbon-3.0.so.0 /usr/local/lib/libwx_gtk2u_xrc-3.0.so.0
/usr/local/lib/libwx_baseu_net-3.0.so.0.2.0 /usr/local/lib/libwx_gtk2u_aui-3.0.so.0.2.0 /usr/local/lib/libwx_gtk2u_html-3.0.so.0.2.0 /usr/local/lib/libwx_gtk2u_ribbon-3.0.so.0.2.0 /usr/local/lib/libwx_gtk2u_xrc-3.0.so.0.2.0
/usr/local/lib/libwx_baseu_xml-3.0.so /usr/local/lib/libwx_gtk2u_core-3.0.so /usr/local/lib/libwx_gtk2u_propgrid-3.0.so /usr/local/lib/libwx_gtk2u_richtext-3.0.so
/usr/local/lib/libwx_baseu_xml-3.0.so.0 /usr/local/lib/libwx_gtk2u_core-3.0.so.0 /usr/local/lib/libwx_gtk2u_propgrid-3.0.so.0 /usr/local/lib/libwx_gtk2u_richtext-3.0.so.0
/usr/local/lib/libwx_baseu_xml-3.0.so.0.2.0 /usr/local/lib/libwx_gtk2u_core-3.0.so.0.2.0 /usr/local/lib/libwx_gtk2u_propgrid-3.0.so.0.2.0 /usr/local/lib/libwx_gtk2u_richtext-3.0.so.0.2.0
$

I recently had to compile KiCad from source on linux. Here’s the list of steps I followed to do that.

I started with a new install of 64-bit Ubuntu Linux 18.04, so I had to install the tools that would let me compile KiCad:

sudo apt install cmake g++ bison flex automake libtool

Then, I edited the /etc/apt/sources.list file and uncommented all the deb-src entries.
This will let apt find source files for packages.

sudo apt edit-sources  # uncomment deb-src items.

Or, you could do it with a sed script:

sudo sed 's/# deb-src/deb-src/' < /etc/apt/sources.list > /etc/apt/sources.list

The next two commands load the KiCad PPA and install the dependencies for building it:

sudo add-apt-repository ppa:js-reynaud/ppa-kicad
sudo apt build-dep kicad

I found that not all the dependencies were handled by the PPA, so there were a few more packages I had to install:

sudo apt install libglm-dev liboce-*-dev libboost-all-dev

Then I updated all the software (just to be sure):

sudo apt update
sudo apt upgrade

Finally, I can load the latest source files for KiCad:

git clone https://git.launchpad.net/kicad

After installing the KiCad source, the first thing I do is run a script to compile the ngspice libraries that allow simulation:

chmod +x kicad/scripting/build_tools/get_libngspice_so.sh
sudo kicad/scripting/build_tools/get_libngspice_so.sh
sudo kicad/scripting/build_tools/get_libngspice_so.sh install

With that out of the way, I create a directory where the main KiCad compilation can take place:

mkdir -p kicad/build/release
cd kicad/build/release

Next, I create the makefile for building KiCad:

cmake -DCMAKE_BUILD_TYPE=Release ../../

If all the dependencies have been installed, I should now have a makefile I can use to build and install the KiCad executables:

make
sudo make install

The next command makes sure KiCad can find all the shared libraries it needs to run:

sudo ldconfig

Now I’ll install the KiCad symbol and footprint libraries:

cd ~
git clone https://github.com/KiCad/kicad-symbols.git
git clone https://github.com/KiCad/kicad-footprints.git

The files with the lists of symbol and footprint files are moved into a directory where KiCad can find them:

mkdir .config/kicad
cp kicad-symbols/sym-lib-table .config/kicad
cp kicad-footprints/fp-lib-table .config/kicad

Then, I create a file that initializes the environment variables KiCad uses with the table files to find the symbols and footprints:

cat << EOF > ~/.kicadrc
export KISYSMOD=~/kicad-footprints
export KICAD_SYMBOL_DIR=~/kicad-symbols
EOF

Finally, I update my .bashrc file so it will set the KiCad environment variables whenever I open a terminal window:

echo  "source ~/.kicadrc" >> .bashrc

If everything went as planned, I should be able to run KiCad:

source .bashrc
kicad
5 Likes

What patched wxWidgets? You don’t need that on linux, use whatever is in your distro’s repository.
If you know for sure that you do need custom patched version of wxwidgets then you have to figure out how this cmake module works
CMakeModules/FindwxWidgets.cmake
and why it ignores your passed arguments -DwxWidgets_INCLUDE_DIRS=/usr/local/include/wx-3.0 -DwxWidgets_LIBRARIES=/usr/local/lib

I patched it myself. I’m following the instructions at http://docs.kicad.org/doxygen/md_Documentation_development_compiling.html where it says " wxWidgets is the graphical user interface (GUI) library used by KiCad. The current minimum version is 3.0.0. However, 3.0.2 should be used whenever possible as there are some known bugs in prior versions that can cause problems on some platforms. Please note that there are also some platform specific patches that must be applied before building wxWidgets from source. These patches can be found in the patches folder in the KiCad source. These patches are named by the wxWidgets version and platform name they should be applied against. wxWidgets must be built with the –with-opengl option. If you installed the packaged version of wxWidgets on your system, verify that it was built with this option." It doesn’t say it’s not need on Linux. What makes you think that’s the case?

Here are the steps I recorded (some may be unnecessary as I had to try several versions of e.g. libcurl before I found the right one):

apt install git libtool automake autoconf
apt install gcc build-essential libc-dev libboost-all-dev
apt install freeglut3 freeglut3-dev libglew-dev libglm-dev
apt install swig swig-dev libgtk-3-dev libcairo2-dev gtk2.0
apt install liboce-ocaf-dev liboce-foundation-dev liboce-visualization-dev
apt install libcurl4-openssl-dev
apt install python-wxtools

cd
mkdir -p ~/kicad-install

git clone https://git.launchpad.net/kicad

wget https://github.com/wxWidgets/wxWidgets/archive/v3.0.2.tar.gz
tar xvfz v3.0.2.tar.gz
cd wxWidgets-3.0.2/
patch -p1 < ~/kicad/patches/wxwidgets-3.0.2_mingw_fix_unicode_entry.patch
patch -p1 < ~/kicad/patches/wxWidgets-3.0.2-msw-dc-orientation-fix.patch
autoconf
./configure --with-opengl
make -j10
sudo make install

cd …
git clone https://git.code.sf.net/p/ngspice/ngspice ngspice
cd ngspice
git checkout ngspice-30-2
./autogen.sh
./configure --with-ngshared
make -j10
sudo make install

sudo ldconfig

cd …/kicad
mkdir -p build/{release,debug}
cd build/debug
cmake -DCMAKE_BUILD_TYPE=Debug -DwxWidgets_INCLUDE_DIRS=/usr/local/include/wx-3.0 -DwxWidgets_LIBRARIES=/usr/local/lib -DNGSPICE_INCLUDE_DIR=/usr/local/include/ngspice -DCMAKE_INSTALL_PREFIX=/home/bson/kicad-install …/…/

You are neither using mingw nor compiling on windows so why are you applying those patches?
Remove your custom wxwidgets and just do apt-get install libwxgtk3.0-gtk3-dev

Did you try without this? Because I think apt buld-dep takes care of these, too, except maybe cmake. What about git, was it installed by default?

Because the instructions say “Please note that there are also some platform specific patches that must be applied before building wxWidgets from source.”

It doesn’t say they’re toolchain, or system, or distro specific.

By platform they mean windows/linux/macos. None of those patches are for linux. And even for windows you don’t need any patches unless you are trying to compile with mingw which is not recommended anymore.

You’re right. I repeated the procedure and it ends up that after the apt-build, I just needed to explicitly install these libraries:

sudo apt install bison flex libglm-dev liboce-*-dev libboost-test-dev

It appears that the apt-build installs both git and cmake as well as the other tools. bison and flex were missing and needed for building the ngspice library, and libglm-dev, liboce-*-dev, and libboost-test-dev were needed for the main KiCad compile.

@devbisme, if I use your method to compile a test executable of kicad in debian stretch, how would I modify it so that it does not overwrite my existing kicad 5.0.2 at /usr/bin/kicad, but rather writes the executable to some development version of the executable ? Just so I have the stable version to fall back on for doing real work.
My stable version is
Version: 5.0.2+dfsg1-1~bpo9+1, release build
Libraries:
wxWidgets 3.0.2
libcurl/7.52.1 OpenSSL/1.0.2s zlib/1.2.8 libidn2/0.16 libpsl/0.17.0 (+libidn2/0.16) libssh2/1.7.0 nghttp2/1.18.1 librtmp/2.3
Platform: Linux 4.9.0-8-amd64 x86_64, 64 bit, Little endian, wxGTK
Build Info:

 wxWidgets: 3.0.2 (wchar_t,wx containers,compatible with 2.8) GTK+ 2.24

 Boost: 1.62.0

 OpenCASCADE Community Edition: 6.8.0

 Curl: 7.52.1

 Compiler: GCC 6.3.0 with C++ ABI 1010

Build settings:

 USE_WX_GRAPHICS_CONTEXT=OFF
 USE_WX_OVERLAY=OFF
 KICAD_SCRIPTING=ON
 KICAD_SCRIPTING_MODULES=ON
 KICAD_SCRIPTING_WXPYTHON=ON
 KICAD_SCRIPTING_ACTION_MENU=ON
 BUILD_GITHUB_PLUGIN=ON
 KICAD_USE_OCE=ON
 KICAD_USE_OCC=OFF
 KICAD_SPICE=ON

If you use the cmake-gui program, you can set the CMAKE_INSTALL_PREFIX and DEFAULT_INSTALL_PATH to be something other than /usr/local. That might keep your build from interfering with your 5.0.2. You’ll just have to make some alias to point to your build version when you want to run it. You can probably use the same symbol and footprint libs for both.

I’ve never done this.

1 Like

No need to use some GUI tools for manipulating the build. I typically build a local version this way.

$ mkdir -p /path/to/build-dir && cd /path/to/build-dir
$ cmake /path/to/source -DKICAD_SCRIPTING_ACTION_MENU=ON \
                        -DKICAD_SCRIPTING_PYTHON3=ON \
                        -DKICAD_SCRIPTING_WXPYTHON_PHOENIX=ON \
                        -DKICAD_SCRIPTING_WXPYTHON=ON \
                        -DKICAD_SCRIPTING_MODULES=ON \
                        -DKICAD_SPICE=ON \
                        -DKICAD_USE_OCE=ON \
                        -DCMAKE_INSTALL_PREFIX=/path/to/your/local-kicad-install \
                        -DCMAKE_CXX_COMPILER=/usr/bin/clang++ \
                        -DCMAKE_C_COMPILER=/usr/bin/clang'

To run your local build you need to set LD_LIBRARY_PATH also.

$ LD_LIBRARY_PATH=/path/to/your/local-kicad-install/lib /path/to/your/local-kicad-install/bin/kicad

1 Like

The default installation path is /usr/local, so you should be safe even if you don’t change the paths with cmake yourself.

This is so old that while you’re at it, compile the 5.1 branch and install it to a third location. You will get the most up to date stable version.

For Mint, there should be no need to build. Just download the Ubuntu package and install it:

BTW, there is also a DMG package for Mac:

Of course if there is a specific reason for trying to build from source (such as wanting to install nightly development builds) then that is another matter.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.