KiCad Tip: Shared Component Libraries

KiCad Tip: Shared Component Libraries

I use KiCad for all my PCB design needs - It has pretty much everything you need. Of course, Altium or Orcad may be way better at doing things, but you can get the same things done in KiCad, but may with a little less productivity, but hey, you get it for absolutely free. Cant ask for more!

Extra Libraries

99% of the time, you will need to make symbols or footprints of your own, for parts that are not available in the official KiCad repositories. When someone else needs to make some changes on it, then managing the project's libraries can get a bit tedious. This write up describes the optimal way (at least I think so) one can do that.

Whats the problem here?

So, the issue I'm trying to address here is that, when you add a library to your project, it can be added in two ways:

  • Relative path
  • Absolute path

The former is the most obvious choice when you want someone else to be able to work on the library easily. Otherwise, every time the other person updates the project, your KiCad installation will have hiccups finding the additional library.

The issue with relative path is that every time a new project is created, the library has to be manually copied to the project directory. This is not very ideal if, like me, you have the library in a separate git repo, as there will inconsistent version of library among different projects.

Another solution is to add a user defined search path for the project where the git repo of the library resides. But it needs to be done manually to the project file with all the collaborator's library absolute library path. This is because of the way KiCad handles user defined search path, as KiCad just removes any invalid search paths set by another user when you add your search path to the project file.

The Solution

Environment Variables to the rescue!

The best solution I've found out, involves a one-time setup per each user's installation for any number of projects.

Project Initiator

The first person who creates the project, should:

  1. Add the library in (relative path) from Eeschema's Preferences -> Component Libraries. Lets name it awesome-library so that the file name becomes awesome-library.lib
  2. Open the .pro file in a text editor, replace the setting LibDir to LibDir=${ENV_VAR}. Choose a name of your choice, instead of ENV_VAR.
  3. Assume that the git repo of the library on the disk is/path/to/awesome-library-git
  4. Open any KiCad project file (.pro extension) in KiCad
  5. From the Project explorer, go to Preferences -> Configure Paths
  6. Add a new environment variable, same as ENV_VAR, or the one you chose, with its value being the absolute path of the folder where .lib and .dcm files reside. Eg., if the actual library resides in /path/to/awesome-library-git/some-folder/awesome-library.lib, then the value would be /path/to/awesome-library-git/some-folder
  7. Restart KiCad

Now push your changes to the new project to your git server so that others can collaborate.

Everybody else

Everyone else, who now wishes to collaborate, must find what is the ENV_VAR the project initiator chose, and follow steps 3 through 7.

Enjoy!