Build From Source Ubuntu Error[OPEN]

Hi everyone,

I’m trying to build kicad from source on ubuntu 20.04.

I cloned the codes from the link git clone kicad - [no description].

I published screnshoots of my terminal.
The file with my source code, which I named kicad.It is in the kicad_build folder.
I created build folder after that I created release folder in that build folder.Then I choosed release directory.When i want to cmake the files some errors are detected.I shared all steps that I did.I also shared CMakeErrorLog file.Does anyone know what the problem is and how i can fix it?

[UPDATE]

Hi , thank you for all replies.

I’ll share the steps how I fixed errors :
I changed build options.
First of all.I cloned KiCad source code to a file.(I named that file target.)
The source code link that I used.: KiCad / KiCad Source Code / kicad · GitLab (Thank you @imcinerney )
-I choosed the directory.(cd target/kicad)
-I created a build folder into kicad(mkdir build)(thank you @jos for the steps )
-I choosed the build directory(cd build).
And after these steps I changed build options of cmake.
-I wrote( cmake -DCMAKE_BUILD_TYPE=Release -DwxWidgets_USE_DEBUG=OFF -DKICAD_SCRIPTING_WXPYTHON=OFF -DKICAD_USE_OCC=OFF -DKICAD_USE_OCE=OFF
-DKICAD_SCRIPTING=OFF -DKICAD_SCRIPTING_MODULES=OFF …)
-I did not get error here.And I wrote: make
-I wrote sudo make install.
And… Done…

I have new questions…
When I click add a symbol button , I get an error message.What is it mean? How can I fix it? I uploaded a screen shot.

clone source > target
cd target/kicad
mkdir build
cd build
cmake …
make
install

works every time

if things get messed up just start over since it does not take that long to clone

You can also try this: Build from source - simple instructions to compile KiCad for some Linux distributions

I haven’t updated the instructions for the possible latest distro versions, but the procedure should be the same.

You may have some problem with your development tool chain (compiler etc.) and installing the build dependencies for a KiCad package might fix that.

1 Like

You should not be using the launchpad link to get any sources for KiCad anymore, it was moved to GitLab in early 2020 and Launchpad is not guaranteed to contain up-to-date sources. The proper place to clone the KiCad git repo from is: KiCad / KiCad Source Code / kicad · GitLab

1 Like

Thanks for the reply,I did what you said but now I got new error.
*** OpenCascade header files missing ***
Verify your OpenCascade installation or pass CMake
the header directory as ‘-DOCC_INCLUDE_DIR=’

CMake Error at CMakeModules/FindOCC.cmake:171 (message):
Call Stack (most recent call first):
CMakeLists.txt:772 (find_package)

– Configuring incomplete, errors occurred!
See also “/home/bernard/target/kicad/build/CMakeFiles/CMakeOutput.log”.
See also “/home/bernard/target/kicad/build/CMakeFiles/CMakeError.log”.

I shared CMakeErrorLog file:
Performing C++ SOURCE FILE Test COMPILER_SUPPORTS_WINCONSISTENT_MISSING_OVERRIDE failed with the following output:
Change Dir: /home/bernard/target/kicad/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_f9ac8/fast && /usr/bin/make -f CMakeFiles/cmTC_f9ac8.dir/build.make CMakeFiles/cmTC_f9ac8.dir/build
make[1]: Entering directory ‘/home/bernard/target/kicad/build/CMakeFiles/CMakeTmp’
Building CXX object CMakeFiles/cmTC_f9ac8.dir/src.cxx.o
/usr/bin/c++ -DCOMPILER_SUPPORTS_WINCONSISTENT_MISSING_OVERRIDE -fPIE -Winconsistent-missing-override -std=c++17 -o CMakeFiles/cmTC_f9ac8.dir/src.cxx.o -c /home/bernard/target/kicad/build/CMakeFiles/CMakeTmp/src.cxx
c++: error: unrecognized command line option ‘-Winconsistent-missing-override’
make[1]: *** [CMakeFiles/cmTC_f9ac8.dir/build.make:66: CMakeFiles/cmTC_f9ac8.dir/src.cxx.o] Error 1
make[1]: Leaving directory ‘/home/bernard/target/kicad/build/CMakeFiles/CMakeTmp’
make: *** [Makefile:121: cmTC_f9ac8/fast] Error 2

Source file was:
int main() { return 0; }
Performing C++ SOURCE FILE Test COMPILER_SUPPORTS_WMISMATCHED_TAGS failed with the following output:
Change Dir: /home/bernard/target/kicad/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_7167d/fast && /usr/bin/make -f CMakeFiles/cmTC_7167d.dir/build.make CMakeFiles/cmTC_7167d.dir/build
make[1]: Entering directory ‘/home/bernard/target/kicad/build/CMakeFiles/CMakeTmp’
Building CXX object CMakeFiles/cmTC_7167d.dir/src.cxx.o
/usr/bin/c++ -DCOMPILER_SUPPORTS_WMISMATCHED_TAGS -fPIE -Wmismatched-tags -std=c++17 -o CMakeFiles/cmTC_7167d.dir/src.cxx.o -c /home/bernard/target/kicad/build/CMakeFiles/CMakeTmp/src.cxx
c++: error: unrecognized command line option ‘-Wmismatched-tags’
make[1]: *** [CMakeFiles/cmTC_7167d.dir/build.make:66: CMakeFiles/cmTC_7167d.dir/src.cxx.o] Error 1
make[1]: Leaving directory ‘/home/bernard/target/kicad/build/CMakeFiles/CMakeTmp’
make: *** [Makefile:121: cmTC_7167d/fast] Error 2

Source file was:
int main() { return 0; }
Performing C++ SOURCE FILE Test COMPILER_SUPPORTS_WIMPLICIT_FLOAT_CONVERSION failed with the following output:
Change Dir: /home/bernard/target/kicad/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_9e57a/fast && /usr/bin/make -f CMakeFiles/cmTC_9e57a.dir/build.make CMakeFiles/cmTC_9e57a.dir/build
make[1]: Entering directory ‘/home/bernard/target/kicad/build/CMakeFiles/CMakeTmp’
Building CXX object CMakeFiles/cmTC_9e57a.dir/src.cxx.o
/usr/bin/c++ -DCOMPILER_SUPPORTS_WIMPLICIT_FLOAT_CONVERSION -fPIE -Wimplicit-int-float-conversion -std=c++17 -o CMakeFiles/cmTC_9e57a.dir/src.cxx.o -c /home/bernard/target/kicad/build/CMakeFiles/CMakeTmp/src.cxx
c++: error: unrecognized command line option ‘-Wimplicit-int-float-conversion’
make[1]: *** [CMakeFiles/cmTC_9e57a.dir/build.make:66: CMakeFiles/cmTC_9e57a.dir/src.cxx.o] Error 1
make[1]: Leaving directory ‘/home/bernard/target/kicad/build/CMakeFiles/CMakeTmp’
make: *** [Makefile:121: cmTC_9e57a/fast] Error 2

Source file was:
int main() { return 0; }

I cloned it from github as you said. But again I got the error. I posted the error in Jos’ answer. Can you take a look at the feedback?

These suggest that your C++ compiler isn’t recent enough, or the tests for the compiler version got it wrong. Try cleaning the source tree (not sure what the cmake command for that is) before building as there may be artefacts for a more recent compiler version checked in from another build.

Also what does

c++ --version

print out? Also do:

dpkg -l gcc g++

I added some build options and now I got :

bernard@bernard-VirtualBox:~/target/kicad/build$ cmake -DCMAKE_BUILD_TYPE=Release -DwxWidgets_USE_DEBUG=OFF -DKICAD_SCRIPTING_WXPYTHON=OFF -DKICAD_SCRIPTING=OF -DKICAD_USE_OCC=OFF -D KICAD_USE_OCE=OFF -DKICAD_SCRIPTING_MODULES=OFF …

– KiCad install dir: </usr/local>
– Enabling warning -Wsuggest-override
– Enabling warning -Wduplicated-branches
– Enabling warning -Wduplicated-cond
– Enabling error for -Wvla
– Enabling warning -Wimplicit-fallthrough
– Enabling error for -Wreturn-type
– Enabling warning -Wshadow
– Enabling warning -Wsign-compare
– Enabling warning -Wmissing-field-initializers
– Enabling warning -Wempty-body
– Enabling warning -Wreorder
– Disabling warning -Wpsabi
– Check for installed GLEW – found
– Check for installed ZLIB – found
– Found the following HarfBuzz libraries:
– HarfBuzz (required): /usr/lib/x86_64-linux-gnu/libharfbuzz.so
– Found SWIG: /usr/bin/swig4.0 (found suitable version “4.0.1”, minimum required is “3.0”)
– pybind11 v2.7.1
– Found PythonInterp: /usr/bin/python3 (found version “3.8.10”)
– Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.8.so
– Performing Test HAS_FLTO
– Performing Test HAS_FLTO - Success
– Found PythonInterp: /usr/bin/python3 (found suitable version “3.8.10”, minimum required is “3.6”)
– Check for installed Python Interpreter – found
– Python module install path: lib/python3/dist-packages
– Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.8.so (found suitable version “3.8.10”, minimum required is “3.6”)
– Found / (wxWidgets )
– Found wxWidgets: -L/usr/lib/x86_64-linux-gnu;-pthread;;;-lwx_gtk3u_gl-3.0;-lwx_gtk3u_aui-3.0;-lwx_gtk3u_adv-3.0;-lwx_gtk3u_html-3.0;-lwx_gtk3u_core-3.0;-lwx_baseu_net-3.0;-lwx_baseu-3.0;-lwx_gtk3u_propgrid-3.0;-lwx_baseu_xml-3.0;-lwx_gtk3u_stc-3.0;-lwx_gtk3u_richtext-3.0 (found version “3.0.4”)
– Found Doxygen: /usr/bin/doxygen (found version “1.8.17”) found components: doxygen missing components: dot
– Found UnixCommands: /usr/bin/bash
– Checking for module ‘gtk±3.0’
– Found gtk±3.0, version 3.24.20
– S3DSG version: 2.0.0
– Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found version “1.71.0”) found components: unit_test_framework filesystem system
– Found wxWidgets: -L/usr/lib/x86_64-linux-gnu;-pthread;;;-lwx_gtk3u_gl-3.0;-lwx_gtk3u_aui-3.0;-lwx_gtk3u_adv-3.0;-lwx_gtk3u_html-3.0;-lwx_gtk3u_core-3.0;-lwx_baseu_net-3.0;-lwx_baseu-3.0;-lwx_baseu_xml-3.0;-lwx_gtk3u_stc-3.0 (found suitable version “3.0.4”, minimum required is “3.0.0”)
– Configuring done
CMake Warning (dev) at thirdparty/3dxware_sdk/CMakeLists.txt:33 (add_library):
Policy CMP0063 is not set: Honor visibility properties for all target
types. Run “cmake --help-policy CMP0063” for policy details. Use the
cmake_policy command to set the policy and suppress this warning.

Target “TDxNavlib” of type “STATIC_LIBRARY” has the following visibility
properties set for CXX:

CXX_VISIBILITY_PRESET
VISIBILITY_INLINES_HIDDEN

For compatibility CMake is not honoring them for this target.
This warning is for project developers. Use -Wno-dev to suppress it.

– Generating done
CMake Warning:
Manually-specified variables were not used by the project:

KICAD_SCRIPTING

– Build files have been written to: /home/bernard/target/kicad/build

c++ --version
c++ (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

bernard@bernard-VirtualBox:~$ dpkg -l gcc g++
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
++±==============-================-============-=================================
ii g++ 4:9.3.0-1ubuntu2 amd64 GNU C++ compiler
ii gcc 4:9.3.0-1ubuntu2 amd64 GNU C compiler

What’s wrong ? I did not understand…

You have gcc 9.4 from 2019 which is probably ok. Mine (not Ubuntu) is 7.5 and I have not heard of problems compiling with on this distro as KiCad packages are available. Most likely it’s to do with the options you are building with. Sorry, I’m not a developer so this is as much as I know.

BTW is there a reason you want to build your own instead of using the prebuilt packages?

Yes I will use kicad source code to write a similar software to do something like EEschema.So I want to build the cpp files of kicad on ubuntu.Especially netlist parser class and the functions of it.By the way, Does anyone know of a way to get the XML form of netlist?Or is it possible?

OCC is 7.5.2 these days and most likely outdated in 20.04

your wxWidgets would appear to be somewhat older as well
in my case I cloned wxWidgets master from their github(?) site
this will give a wxWidgets 3.1.6 currently

as already mentioned earlier by others, there are quite a few pieces to be put in place beforehand!

follow the ‘how to compile from source’ suggestions on the kicad site
it covers all software requirements

It’s a bit of a job at first but worth it

good luck

Why not use the stock schematic editor and write a S-expression to XML translator? Should be a much smaller job, especially if done in a scripting language where you can use a package that parses S-expressions, like Python and sexpdata.

These don’t matter - they are supposed to fail in the CMake log on older compilers because CMake is checking if the compiler supports them, so they aren’t the problem. The problem is the first error that was posted, which is the missing OpenCascade (occt) dependency.

There are no CMake errors shown in that output so you should be able to just run make and have it work. Note though that you have disabled the 3D viewer and appear to be using many CMake options that actually don’t exist in the newest KiCad releases - so which version are you trying to compile?

If you add options to the cmake command you create conflicts with

CMakeLists.txt in the kicad root folder

This file already contains all relevant options inclusive explanations.

I don’t think OCC AND OCE both set to off is useful!

Hi.I m trying to compile 6.0.4 version of KiCad.
I always got an error without set off build properties OCC and OCE.
I actually,when I wrote these cmake build options, I didn’t get any error and I was able to build.Frankly, my goal is to add or remove some new tools to the toolbar on the eeschema side. Would turning off the build options I wrote on the Cmake side cause me trouble in this regard?
-DCMAKE_BUILD_TYPE=Release -DwxWidgets_USE_DEBUG=OFF -DKICAD_SCRIPTING_WXPYTHON=OFF -DKICAD_SCRIPTING=OF -DKICAD_USE_OCC=OFF -D KICAD_USE_OCE=OFF -DKICAD_SCRIPTING_MODULES=OFF …

Did you ever try the instructions in How to build KiCad on Ubuntu (the easy way) · Wiki · eelik-kicad / kicad · GitLab? Last time I checked it has worked without problems, although I don’t remember anymore if I have tried 20.04/KiCad6 combination. The only thing different in your situation is that you want to enable the source repository for 6.0, not for nightly builds.

Done it 20.04
works a treat :+1:
especially with the very useful ‘How to build KiCad on Ubuntu …’

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