Notes on Building on Debian 12

I’m working on a project to build a board using the espressif libraries on Debian 12, bookwork. Unfortunately even the version of KiCad on Debain is even too old for the version 6 libraries, so I have found the need to build from source.

Checking out the commit on the version 6 development branch.
2bc8c0ace5e927bc7a5bd7a630d436f488e79a38
and building with cmake. Yikes!

Eventually you will come across

*** OpenCascade library missing ***
Could not find a library for TKBinXCAF at /usr/lib/x86_64-linux-gnu
Verify your OpenCascade installation or pass CMake
  the library directory as '-DOCC_LIBRARY_DIR=<path>'

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

This is fundamentally a Debian issue, so the way to fix it is to download the package liboce-ocaf11. Although this package downloads the libraries, it does not create the symbolic links /usr/lib/x86_64-linux-gnu/libTKBinXCAF.so to point to /usr/lib/x86_64-linux-gnu/libTKBinXCAF.so.7. But the KiCad build process let’s us work around this.

mkdir libhints
cd libhints/
ln -s /usr/lib/x86_64-linux-gnu/libTKBinXCAF.so.7 libTKBinXCAF.so
ln -s /usr/lib/x86_64-linux-gnu/libTKIGES.so.7 libTKIGES.so
ln -s /usr/lib/x86_64-linux-gnu/libTKMeshVS.so.7 libTKMeshVS.so
ln -s /usr/lib/x86_64-linux-gnu/libTKOpenGl.so.7 libTKOpenGl.so
ln -s /usr/lib/x86_64-linux-gnu/libTKSTEP209.so.7 libTKSTEP209.so
ln -s /usr/lib/x86_64-linux-gnu/libTKSTEPAttr.so.7 libTKSTEPAttr.so
ln -s /usr/lib/x86_64-linux-gnu/libTKSTEPBase.so.7 libTKSTEPBase.so
ln -s /usr/lib/x86_64-linux-gnu/libTKSTEP.so.7 libTKSTEP.so
ln -s /usr/lib/x86_64-linux-gnu/libTKSTL.so.7 libTKSTL.so
ln -s /usr/lib/x86_64-linux-gnu/libTKTObj.so.7 libTKTObj.so
ln -s /usr/lib/x86_64-linux-gnu/libTKTopAlgo.so.7 libTKTopAlgo.so
ln -s /usr/lib/x86_64-linux-gnu/libTKV3d.so.7 libTKV3d.so
ln -s /usr/lib/x86_64-linux-gnu/libTKVRML.so.7 libTKVRML.so
ln -s /usr/lib/x86_64-linux-gnu/libTKXCAF.so.7 libTKXCAF.so
ln -s /usr/lib/x86_64-linux-gnu/libTKXDEIGES.so.7 libTKXDEIGES.so
ln -s /usr/lib/x86_64-linux-gnu/libTKXDESTEP.so.7 libTKXDESTEP.so
ln -s /usr/lib/x86_64-linux-gnu/libTKXMesh.so.7 libTKXMesh.so
ln -s /usr/lib/x86_64-linux-gnu/libTKXmlL.so.7 libTKXmlL.so
ln -s /usr/lib/x86_64-linux-gnu/libTKXml.so.7 libTKXml.so
ln -s /usr/lib/x86_64-linux-gnu/libTKXmlTObj.so.7 libTKXmlTObj.so
ln -s /usr/lib/x86_64-linux-gnu/libTKXmlXCAF.so.7 libTKXmlXCAF.so
ln -s /usr/lib/x86_64-linux-gnu/libTKXSBase.so.7 libTKXSBase.so

In the file FindOCC.cmake
Set the line

find_library(OCC_TEMP_LIB ${lib} HINTS ${OCC_LIBRARY_DIR} NO_DEFAULT_PATH)

to

find_library(OCC_TEMP_LIB ${lib} HINTS ${OCC_LIBRARY_DIR} ${OCC_HINT} 
NO_DEFAULT_PATH)

Then you can go back to your build directory and run

cmake .. -DOCC_HINT=[Absolute-Path-to-KiCad-Project]/libhints/

Really?

HaHa! @tijuca you’re right!

My advice in my opening post is terrible. Pounding on the keyboard lead to findin out you need these packages to have the libraries needed to build.

sudo aptitude install libocct-data-exchange-7.6 libocct-data-exchange-dev libocct-doc libocct-draw-7.6 libocct-draw-dev libocct-foundation-7.6 libocct-foundation-dev libocct-modeling-algorithms-7.6 libocct-modeling-algorithms-dev libocct-modeling-data-7.6 libocct-modeling-data-dev libocct-ocaf-7.6 libocct-ocaf-dev libocct-visualization-7.6 libocct-visualization-dev occt-draw occt-misc

But you do not have to build in the first place. and if you’re stuck running KiCad 6.0.11 and you want to use the espressif footprint libraries from GitHub - espressif/kicad-libraries: KiCad libraries for Espressif chips and modules, then you can check out the 1.0.0 tag.