How to Build IPC API for Cpp Plugin Development?

I am trying to port my plugin from python to cpp to get faster calculations with a “stable plugin without type exceptions”.

I got the kiapi libraries by compiling the kicad source code.
image

But I can’t use the associated header file because it’s full of errors, and it looks like the required protobuf header file isn’t missing.

The strangest thing is that he can’t parse the protobuf version, he has to use #include “google/protobuf/runtime_version.h” before the kiapi header file, and if he compiles at that point, although he won’t throw an (

#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.

) error, he’ll get tons of syntax errors.

I tried generating the kiapi source and header files separately using protoc command line, again lots of errors and no way to compile it into a library.

Since it compiles in the kicad source, that proves that the kiapi header files are fine. How do I configure my project to use these headers properly?

The package manager I use is conan.
And the project compiles fine without introducing kiapi headers anymore.

Currently my CMakeLists.txt :

cmake_minimum_required(VERSION 3.31)
project(KicadTools)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_VS_GLOBALS "VcpkgEnabled=false")
set_property(GLOBAL PROPERTY KICAD_CMAKE_MODULE_PATH "E:/Sources/kicad/cmake")
include_directories(KiApi)
add_subdirectory(DiffGen)
link_libraries(KiApi/kiapi.lib)

I don’t want to continue developing plugins in Python, due to the nature of the language I have to put more effort into making sure that the types of the runtime function parameters are correct, and the type annotations that are everywhere. With cpp I don’t need to care about the correct type of parameter types.

I do not think you will get much C++ help from a KiCad users forum.

The kiapi folder is not designed to provide a standalone library for use in third party plugins. So, if you’re trying to do that, you’re probably going to need to modify some things.

You will need to look at the differences between your CMake setup and KiCad’s. You also need to pay attention to the protobuf documentation; the warning it’s giving you is accurate. You can’t use a different version of protobuf between protoc and the libraries you’re trying to build and link against. Fixing this will come down to your package manager, probably.

Thanks, I’ll try to go to gitlab for help, the kiapi content is just for generating the protobuf base call code for the language, referring to kicad-python I should still need to call it at the wrapper layer.

FYI. the API seems to support rust out of the box - you might want to consider rust instead of C++

GitLab is not for help, it’s for tracking development work. If you need help with C++/protobuf in general I’d say try reddit, stackoverflow, AI chat, etc. If you need help with KiCad development in specific, the developers’ email list.

From the initial post it sounds like your issue is with understanding how protobuf needs to be compiled in C++, which is not a KiCad-specific issue.