Fixing eeshow library lookup (not found) another option

I’m using KiCad 5.1.5 on Debian 10.3. The propposed patch in:

Isn’t enough for me. I proppose the following patch:

--- a/kicad/lib-render.c
+++ b/kicad/lib-render.c
@@ -716,6 +716,9 @@
 	const struct comp *comp;
 	const struct comp_alias *alias;
+	char *lib_sep = strchr(name, ':');
+	if (lib_sep) *lib_sep ='_';
 	for (comp = lib->comps; comp; comp = comp->next) {
 		if (!strcmp(comp->name, name))
 			return comp;
--- a/kicad/pro.c
+++ b/kicad/pro.c
@@ -50,6 +50,19 @@
+static void add_lib(struct file_names *fn, char *s)
+	char *dot;
+	fn->n_libs++;
+	fn->libs = realloc_type_n(fn->libs, const char *, fn->n_libs);
+	dot = strrchr(s, '.');
+	if (!dot || strcmp(dot, ".lib")) {
+		s = realloc_size(s, strlen(s) + 5);
+		strcat(s, ".lib");
+	}
+	fn->libs[fn->n_libs - 1] = s;
 static bool pro_parse_line(const struct file *file,
     void *user, const char *line)
@@ -79,18 +92,7 @@
 	case pro_libs:
 		if (sscanf(line, "LibName%*u=%ms", &s) == 1) {
-			char *dot;
-			pro->fn->n_libs++;
-			pro->fn->libs = realloc_type_n(pro->fn->libs,
-			    const char *, pro->fn->n_libs);
-			dot = strrchr(s, '.');
-			if (!dot || strcmp(dot, ".lib")) {
-				s = realloc_size(s, strlen(s) + 5);
-				strcat(s, ".lib");
-			}
-			pro->fn->libs[pro->fn->n_libs - 1] = s;
-                        error(" adding lib: %s",s);
+			add_lib(pro->fn, s);
 			return 1;
@@ -129,6 +131,20 @@
 		return NULL;
+        // Add the project cache
+	assert(pro.fn->pro);
+	{
+	char *s, *dot;
+	int l = strlen(pro.fn->pro);
+	s = (char *)malloc(l + 10 + 1);
+	memcpy(s, pro.fn->pro, l + 1);
+	dot = strrchr(s, '.');
+	assert(!strcmp(dot, ".pro"));
+	strcpy(dot, "-cache.lib");
+	add_lib(pro.fn, s);
+	}
 	if (!pro.fn->sch) {
 		char *s, *dot;

This patch does two things:

  1. It forces the load of the project cache (in order to get all the eeshow functionality you must include the cache in the git repo)
  2. It converts modern KiCad component names from LIBRARY:COMPONENT to the format used by the cache: LIBRARY_COMPONENT

With this patch you don’t need to:

  1. Specify extra libraries in the command line
  2. Edit the project to add the used libraries

As long as the cache file is updated you’ll get all the components.

That is about eeshow, a 3rd party program, not about KiCad itself. I didn’t even know such a program existed; I don’t know if your post reaches the target audience, namely those who use eeshow and can patch and compile it.

I put it here because:

  1. I started my patch using what you can find in the following topic (on this forum):
  1. The category is “External Plugins”, which seems more or less what eeshow is.

There’s nothing wrong in posting it here, it’s just that it would have deserved an explanation. I understood your post only after navigating through links.

The general problem with this tool is that it is not hosted on an open platform. I do not quite understand why they use their own git server instead of using github, gitlab, …

This makes it near impossible for the community to fix problems with it. Especially worrying is that the main website seems to not have been updated since 2018 (latest news item)

So I stumbled on this earlier tonight while trying to figure out how I could get my CI pipeline to generate PDFs of my schematics automatically. This quickly sent me down the rabbit hole to this repo / docker container akshmakov/eeshow which may have worked but it didn’t pull in the cache library as elegantly as this patch does.

I ended up making my own copy of eeshow by cloning the original repo to my gitlab account, applied your patch to it, and then created the Dockerfile and gitlab ci file to build an image. I may figure out how to push it to docker hub but for now it’s available here:

See it in action here:

Cool! Nice to know it helped you and that you are making a docker image!!
I’m also in the work to automate KiCad stuff. Mainly to generate consistent fabrication information. I’m uploading various patched tools to the following GitHub group:
I’m using kiplot for gerbers and drill (I patched it to generate the gerber job file) and kicad-automation-scripts to generate PDFs, run ERC/DRC, update the XML BoM, generate the netlist, etc. I heavily patched it to work on my desktop (was really unreliable). For the BoM I’m using KiBoM, also patched, not yet uploaded. I’m also using InteractiveHtmlBom, again patched, but not yet uploaded.
Currently I’m focusing on Debian packages, if I have time I’ll use them with docker for CI.

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