Creating and loading a basic renderer plugin

I am writing a renderer plugin, and trying to start by writing a completely empty one and then filling it in later. From investigating source code I found the implementations of some of the builtin renderers, and their gvrender_engine_t structs are often mostly zero function pointers, so one with entirely zero function pointers should not be a problem to start with, it'll just do nothing. From reading the libguide I concluded that the minimum I should need for a renderer plugin is the code I attached as mylib.cpp.txt.

Of course later I will fill in some of the render engine function pointers and the render features struct as well, but I do not yet need that, nor other types in the gvplugin_installed_t, nor other plugins in the gvplugin_api_t.

My application is very simple and I am able to put that entire code inside it, as well as the function definitions once they exist. I am trying to do the least amount necessary to make a call to this renderer work, so I'd rather have all the renderer code in source than try to make a dll.

With the contents of mylib.cpp accessible inside my project, I expect to be able to run this code or something reasonably similar:

GVC_t *gvc = gvContext();
Agraph_t *G = agopen("G", Agdirected, NULL);
gvAddLibrary(gvc, &gvplugin_mylib_LTX_library); //I expect something like this to add my library
gvLayout(gvc, G, "dot");
gvRender(gvc, G, "mylib", stdout); //so that I can ask for my renderer here
gvFreeLayout(gvc, G);

However, when gvRender is reached, I get "Error: renderer for mylib is unavailable". I get the same error if the gvAddLibrary function and the actual library code are absent, which seems to imply that using gvAddLibrary doesn't do anything with my gvplugin_library_t, or can't find it. (The code does find the "dot" or "plain" or other builtin renderers if I use those names in gvRender, and in general otherwise works.)

I'm having a hard time following the source for this part, so, what should I be doing to actually use my renderer/library?

mylib.cpp_.txt1.73 KB

I wonder whether this issue

I wonder whether this issue is connected with the absence of libexpat. I am not sure, just read about similar situation at What if to try to install expat first? The error you described is most probably connected with the library compatibility.

Recent comments