Kicad build error netlist

Hi, my KiCad5.99 (git master) build on Ubuntu 19 is failing, any ideas what I might be doing wrong? Thanks for the help.

[ 24%] Building CXX object common/CMakeFiles/pcbcommon.dir/__/pcbnew/netlist_reader/kicad_netlist_reader.cpp.o
/opt/kicad/pcbnew/netlist_reader/kicad_netlist_reader.cpp: In member function ‘void KICAD_NETLIST_PARSER::parseNet()’:
/opt/kicad/pcbnew/netlist_reader/kicad_netlist_reader.cpp:241:22: error: ‘T_pinfunction’ was not declared in this scope
                 case T_pinfunction:
                      ^~~~~~~~~~~~~
/opt/kicad/pcbnew/netlist_reader/kicad_netlist_reader.cpp:241:22: note: suggested alternative: ‘pin_function’
                 case T_pinfunction:
                      ^~~~~~~~~~~~~
                      pin_function
/opt/kicad/pcbnew/netlist_reader/kicad_netlist_reader.cpp:247:22: error: ‘T_pintype’ was not declared in this scope
                 case T_pintype:
                      ^~~~~~~~~
/opt/kicad/pcbnew/netlist_reader/kicad_netlist_reader.cpp:247:22: note: suggested alternative: ‘pin_type’
                 case T_pintype:
                      ^~~~~~~~~
                      pin_type
/opt/kicad/pcbnew/netlist_reader/kicad_netlist_reader.cpp: In member function ‘void KICAD_NETLIST_PARSER::parseComponent()’:
/opt/kicad/pcbnew/netlist_reader/kicad_netlist_reader.cpp:371:14: error: ‘T_property’ was not declared in this scope
         case T_property:
              ^~~~~~~~~~
/opt/kicad/pcbnew/netlist_reader/kicad_netlist_reader.cpp:371:14: note: suggested alternative: ‘wxPGProperty’
         case T_property:
              ^~~~~~~~~~
              wxPGProperty

I then erased the build directory and recompiled from scratch. Now getting:

../scripting/libscripting.a(python_scripting.cpp.o): In function `_Py_DECREF':
/usr/include/python3.8/object.h:478: undefined reference to `_Py_Dealloc'
../scripting/libscripting.a(python_scripting.cpp.o): In function `RunPythonMethodWithReturnedString(char const*, wxString&)':
/opt/kicad/scripting/python_scripting.cpp:234: undefined reference to `PyUnicode_AsEncodedString'
../scripting/libscripting.a(python_scripting.cpp.o): In function `PyStringToWx(_object*)':
/opt/kicad/scripting/python_scripting.cpp:320: undefined reference to `PyUnicode_AsEncodedString'
../scripting/libscripting.a(python_scripting.cpp.o): In function `PyArrayStringToWx(_object*)':
/opt/kicad/scripting/python_scripting.cpp:353: undefined reference to `PyUnicode_AsEncodedString'
../scripting/libscripting.a(python_scripting.cpp.o): In function `PyErrStringWithTraceback()':
/opt/kicad/scripting/python_scripting.cpp:393: undefined reference to `PyException_SetTraceback'
/opt/kicad/scripting/python_scripting.cpp:395: undefined reference to `PyUnicode_FromString'
../scripting/libscripting.a(python_scripting.cpp.o): In function `pybind11::str::str(char const*)':
/opt/kicad/thirdparty/pybind11/include/pybind11/pytypes.h:957: undefined reference to `PyUnicode_FromString'
../scripting/libscripting.a(python_scripting.cpp.o): In function `pybind11::str::operator std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >() const':
/opt/kicad/thirdparty/pybind11/include/pybind11/pytypes.h:974: undefined reference to `PyUnicode_AsUTF8String'
/opt/kicad/thirdparty/pybind11/include/pybind11/pytypes.h:980: undefined reference to `PyBytes_AsStringAndSize'
../scripting/libscripting.a(python_scripting.cpp.o): In function `pybind11::detail::internals::~internals()':
/opt/kicad/thirdparty/pybind11/include/pybind11/detail/internals.h:121: undefined reference to `PyThread_tss_free'
../scripting/libscripting.a(python_scripting.cpp.o): In function `pybind11::detail::get_internals()':
/opt/kicad/thirdparty/pybind11/include/pybind11/detail/internals.h:293: undefined reference to `PyThread_tss_alloc'
/opt/kicad/thirdparty/pybind11/include/pybind11/detail/internals.h:294: undefined reference to `PyThread_tss_create'
/opt/kicad/thirdparty/pybind11/include/pybind11/detail/internals.h:296: undefined reference to `PyThread_tss_set'
../scripting/libscripting.a(python_scripting.cpp.o): In function `pybind11::detail::instance::allocate_layout()':
/opt/kicad/thirdparty/pybind11/include/pybind11/detail/type_caster_base.h:388: undefined reference to `PyMem_Calloc'
../scripting/libscripting.a(python_scripting.cpp.o): In function `pybind11::detail::error_string[abi:cxx11]()':
/opt/kicad/thirdparty/pybind11/include/pybind11/detail/type_caster_base.h:432: undefined reference to `PyException_SetTraceback'
../scripting/libscripting.a(python_scripting.cpp.o): In function `pybind11::detail::get_thread_state_unchecked()':
/opt/kicad/thirdparty/pybind11/include/pybind11/detail/type_caster_base.h:481: undefined reference to `_PyThreadState_UncheckedGet'
../scripting/libscripting.a(python_scripting.cpp.o): In function `pybind11::detail::type_caster<bool, void>::load(pybind11::handle, bool)':
/opt/kicad/thirdparty/pybind11/include/pybind11/cast.h:293: undefined reference to `_Py_FalseStruct'
../scripting/libscripting.a(python_scripting.cpp.o): In function `pybind11::gil_scoped_acquire::gil_scoped_acquire()':
/opt/kicad/thirdparty/pybind11/include/pybind11/gil.h:54: undefined reference to `PyThread_tss_get'
/opt/kicad/thirdparty/pybind11/include/pybind11/gil.h:72: undefined reference to `PyThread_tss_set'
../scripting/libscripting.a(python_scripting.cpp.o): In function `pybind11::gil_scoped_acquire::dec_ref()':
/opt/kicad/thirdparty/pybind11/include/pybind11/gil.h:104: undefined reference to `PyThread_tss_set'
../scripting/libscripting.a(python_scripting.cpp.o): In function `pybind11::detail::make_static_property_type()':
/opt/kicad/thirdparty/pybind11/include/pybind11/detail/class.h:62: undefined reference to `PyUnicode_FromString'
../scripting/libscripting.a(python_scripting.cpp.o): In function `pybind11_meta_getattro':
/opt/kicad/thirdparty/pybind11/include/pybind11/detail/class.h:161: undefined reference to `PyInstanceMethod_Type'
../scripting/libscripting.a(python_scripting.cpp.o): In function `pybind11::detail::make_default_metaclass()':
/opt/kicad/thirdparty/pybind11/include/pybind11/detail/class.h:239: undefined reference to `PyUnicode_FromString'
../scripting/libscripting.a(python_scripting.cpp.o): In function `pybind11::detail::make_object_base_type(_typeobject*)':
/opt/kicad/thirdparty/pybind11/include/pybind11/detail/class.h:445: undefined reference to `PyUnicode_FromString'
../scripting/libscripting.a(python_scripting.cpp.o): In function `pybind11::cpp_function::initialize_generic(std::unique_ptr<pybind11::detail::function_record, pybind11::cpp_function::InitializingFunctionRecordDeleter>&&, char const*, std::type_info const* const*, unsigned long)':
/opt/kicad/thirdparty/pybind11/include/pybind11/pybind11.h:374: undefined reference to `PyInstanceMethod_Type'
/opt/kicad/thirdparty/pybind11/include/pybind11/pybind11.h:492: undefined reference to `PyInstanceMethod_New'
../scripting/libscripting.a(python_scripting.cpp.o): In function `pybind11::detail::string_caster<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, false>::decode_utfN(char const*, long)':
/opt/kicad/thirdparty/pybind11/include/pybind11/cast.h:404: undefined reference to `PyUnicode_DecodeUTF8'
../scripting/libscripting.a(python_scripting.cpp.o): In function `pybind11::detail::string_caster<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, false>::load(pybind11::handle, bool)':
/opt/kicad/thirdparty/pybind11/include/pybind11/cast.h:372: undefined reference to `PyUnicode_AsEncodedString'
/opt/kicad/thirdparty/pybind11/include/pybind11/cast.h:376: undefined reference to `PyBytes_AsString'
/opt/kicad/thirdparty/pybind11/include/pybind11/cast.h:377: undefined reference to `PyBytes_Size'
../scripting/libscripting.a(python_scripting.cpp.o): In function `bool pybind11::detail::string_caster<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, false>::load_bytes<char>(std::enable_if<std::is_same<char, char>::value, pybind11::handle>::type)':
/opt/kicad/thirdparty/pybind11/include/pybind11/cast.h:420: undefined reference to `PyBytes_AsString'
/opt/kicad/thirdparty/pybind11/include/pybind11/cast.h:422: undefined reference to `PyBytes_Size'
collect2: error: ld returned 1 exit status
make[2]: *** [bitmap2component/bitmap2component] Error 1
make[1]: *** [bitmap2component/CMakeFiles/bitmap2component.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

Python dependencies changed, run cmake config again.

Note also that these (python related) are linker errors, not compiler errors.

Usually out of tree build directory has the CMakeCache.txt file, so deleting everything and starting from scratch means also reconfiguring. But we don’t know if that happened already.

It’s possible that you don’t have some python package installed. For example something like libpython3-dev or or the non dev libpython3 for the relevant python version.

Thanks for your replies. I deleted the whole build directory, and started from scratch again, but I reach the same error. I am not sure if having a pybind11 installed by pip3 is messing somehow up. (I can’t remove it, I need for other programs).

sudo pip3 install pybind11[global]

Attached the full log. buildlog.txt (85.9 KB)

Another problem might have been that I changed Python3 to the system default some time ago.

There are 2 choices for the alternative python (providing /usr/bin/python).

  Selection    Path                Priority   Status
------------------------------------------------------------
  0            /usr/bin/python2.7   20        auto mode
  1            /usr/bin/python2.7   20        manual mode
* 2            /usr/bin/python3.6   10        manual mode

image

What do you have in these advanced cmake flags?

image

You probably should have libpython3.8.so. Do apt search for libpython and try to find the correct version for the binary and -dev package.

EDIT: no, sorry, your python version is 3.6. So there’s some mismatch anyways because the include dir is for 3.8.

Yes, somehow it got the wrong version of the include dir. I overwrote the variable with /usr/include/python3.6m and I am now trying to rebuild it. Thanks for the hints!

It looks as if the Python errors are now gone, thanks. However, I am getting other errors:

buildlog.txt (34.1 KB)

I recommend starting totally from scratch, including the source code tree.

Wow, couldn’t think that the source code tree was being ‘modified’ during the build. Indeed cloning again from git helped. The build now ‘almost’ completed, it only failed at 99%:

[100%] Building CXX object pcbnew/CMakeFiles/pcbnew_kiface_objects.dir/specctra_import_export/specctra_keywords.cpp.o
/opt/kicad/pcbnew/python/scripting/pcb_scripting_tool.cpp: In member function ‘virtual bool SCRIPTING_TOOL::Init()’:
/opt/kicad/pcbnew/python/scripting/pcb_scripting_tool.cpp:60:34: error: ‘PyImport_GetModule’ was not declared in this scope
     if( PyObject* existing_mod = PyImport_GetModule( mod_name ) )
                                  ^~~~~~~~~~~~~~~~~~
/opt/kicad/pcbnew/python/scripting/pcb_scripting_tool.cpp:60:34: note: suggested alternative: ‘PyImport_AddModule’
     if( PyObject* existing_mod = PyImport_GetModule( mod_name ) )
                                  ^~~~~~~~~~~~~~~~~~
                                  PyImport_AddModule
pcbnew/CMakeFiles/pcbnew_kiface_objects.dir/build.make:4069: recipe for target 'pcbnew/CMakeFiles/pcbnew_kiface_objects.dir/python/scripting/pcb_scripting_tool.cpp.o' failed
make[2]: *** [pcbnew/CMakeFiles/pcbnew_kiface_objects.dir/python/scripting/pcb_scripting_tool.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
CMakeFiles/Makefile2:2304: recipe for target 'pcbnew/CMakeFiles/pcbnew_kiface_objects.dir/all' failed
make[1]: *** [pcbnew/CMakeFiles/pcbnew_kiface_objects.dir/all] Error 2
Makefile:165: recipe for target 'all' failed
make: *** [all] Error 2
12:36:03: The process "/snap/bin/cmake" exited with code 2.
Error while building/deploying project kicad (kit: Desktop)
When executing step "Build"

It looks like this function is only available in Python 3.7, not in 3.6. I reported it here https://gitlab.com/kicad/code/kicad/-/issues/8554

If I comment out a couple of lines in that cpp file, the build finally succeeds. Thanks for all the help!

Indeed it looks like that, and it’s a bug in KiCad (I think). @Seth_h has implemented that file so maybe he can comment.

Thanks.

I had another question. When building, I specified a custom install path, however, when calling make install, I get a mix of stuff. Is this intended, or is it also a bug? Is there a way to specify a custom share directory, in order not to mess up with the root filesystem at /usr?

-- Installing: /usr/local/share/kicad/scripting/plugins/microMatch_connectors.py
-- Installing: /usr/local/share/kicad/scripting/plugins/circular_pad_array_wizard.py
-- Installing: /usr/local/share/kicad/scripting/plugins/qrcode_footprint_wizard.py
-- Installing: /usr/local/share/kicad/scripting/plugins/kicad_qrcode.py
-- Installing: /opt/kicad_install/lib/python3/dist-packages/_pcbnew.so
-- Installing: /opt/kicad_install/bin/pl_editor
-- Installing: /opt/kicad_install/bin/_pl_editor.kiface
-- Installing: /opt/kicad_install/bin/bitmap2component
-- Installing: /opt/kicad_install/bin/pcb_calculator
-- Installing: /opt/kicad_install/bin/_pcb_calculator.kiface
-- Installing: /opt/kicad_install/lib/kicad/plugins/3d/libs3d_plugin_idf.so

Also, I can run and open correctly eeschema, gerber viewer, calc tools, symbol editor, but PCBnew fails to start with the message:

image

I solved it by calling export LD_LIBRARY_PATH=/opt/kicad_install/lib before starting kicad. However I do not know why this is only needed for PCBnew… for the other tools, they are somehow automatically found even without export LD path.

You can define KICAD_RUN_FROM_BUILD_DIR environment variable and run kicad straight from build directory without installing if you want.

1 Like

You can try what qu1ck said. Or go through all build options (also advanced) carefully. I remember the same happening to me but I didn’t find the right cmake variable. I just leave them as default and everything is under /usr/local.

Because it’s a dynamically loaded library which isn’t loaded to “kicad” binary but only to “pcbnew” binary when it’s started. As you can see, it’s related to the 3D viewer or export and isn’t used in the project view, eeschema etc.

See https://gitlab.com/eelik-kicad/kicad/-/wikis/How-to-build-KiCad-on-Linux-(the-easy-way), the Run section for how to make the binary library path permanent. Because you have used /opt/ the basic default sudo ldconfig doesn’t work but you have to add the path manually.

I just found out that if you use ccmake or cmake-gui you have to set -DCMAKE_INSTALL_PREFIX=/opt/kicad_install in the command line when you start the configuration tool. Otherwise paths aren’t recalculated.

1 Like

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