Plugin development: how-to for newbies
Page 1 of 1

Author:  Lusipa [ 14 Jun 2013, 12:36 ]
Post subject:  Plugin development: how-to for newbies


i try to develop a plugin for navit. But the article about plugins on the wiki did not realy help me.
I think i need a step-by-step instruction for building a plugin.

For example I want to know:
- which Makefiles/CMakeLists.txt I have to change?
- where to store my code?
- how to compile to get changes active?
- how to access the plugin?
- what about changing plugin.c/plugin.h/plugin_def.h?

I think having a easy to use and unterstand "how-to develop plugins" is very important to make navit even more atractive for external developers. Further more a download area for navit-plugins would be very cool, so one could customize navit for users purpose (not only by changing the apearance with navit.xml).
For this purpose one could maybe orientatet on There he tries to explain in a very general way how to use plugins in c.
But these are only some big ideas. I'm thankfull for any help.

thanks in advance

Author:  xenos1984 [ 15 Jun 2013, 08:25 ]
Post subject:  Re: Plugin development: how-to for newbies

Having a better documentation for plugin development is certainly a good idea. I don't know completely how to o this, but let me try to answer some of your questions.

Lusipa wrote:
- which Makefiles/CMakeLists.txt I have to change?

I don't know anything about CMake, since I'm used only to autotools (unfortunately support for this will be removed sooner or later, so one has to deal with CMake). In plugin/ I would add the following lines before DIST_SUBDIRS=...:
  SUBDIRS += myplugin

Further, add "myplugin" to the end of the DIST_SUBDIRS=... line (separated with space). Maybe someone can explain how to add the plugin to the CMake part as well.
Lusipa wrote:
- where to store my code?

In my example above I called the plugin MYPLUGIN and the place, where the code should be stored, would be a subfolder of "plugin" in the Navit source tree, which I called myplugin. Of course you can choose any name.
Lusipa wrote:
- how to compile to get changes active?

Are you familiar with compiling Navit in general? I think one also needs to add something to the top level build configuration, so that a variable named PLUGIN_MYPLUGIN is set when you configure Navit with --enable-plugin-myplugin, but I don't see right now, where to do this.
Lusipa wrote:
- how to access the plugin?

For this you need to add this to your navit.xml, where you can find similar plugin lines:
<plugin path="$NAVIT_LIBDIR/*/${NAVIT_LIBPREFIX}" active="yes"/>

Author:  Lusipa [ 19 Jun 2013, 12:13 ]
Post subject:  Re: Plugin development: how-to for newbies

thank you very much, for your fast answer.
but unfortunatly this does not work for me... i guess it is still my fault, since i dont ḱnow much about plugins and navit...maybe, it is also because i dont know how to activate/call my plugin, during navit is running, because compilation works well. maybe someone can tell me how this works.
so maybe an example plugin could also help me understanding how to write an own plugin.
thx for any hint

Author:  usul [ 19 Jun 2013, 14:30 ]
Post subject:  Re: Plugin development: how-to for newbies

Could you please provide us a detailed (higher debug level) startup log of your instance starting?

And no, I guess it's more our fault, as we can't currently provide a good plugin doc ;)

Author:  Lusipa [ 20 Jun 2013, 13:01 ]
Post subject:  Re: Plugin development: how-to for newbies

actually i think that my plugin is recognized now, because if i have a syntax error in myplugin.c the compiler tells me about this error.

But i still dont know, how i can call my plugin while navit is running to do something. e.g. to print a simple cmd-line output.
Refering to i'm looking for a file/function which manages the plugins. Which tells them when and where to hook into navits running process.

I cut the debug log file, because its size was to large to load it up... i cut only one large part in the middle where the word "plugin" isn't mentioned
(if debug level 2 is not detailed enough for you, or you need a not cut debug log file, tell me)

File comment: debug log with debug level = 2
debug_log_global_level_2_snipped.txt [150.26 KiB]
Downloaded 567 times
File comment: cmd-line output from make
make_log.txt [74.69 KiB]
Downloaded 556 times
File comment: cmd-line output from cmake
cmake_log.txt [11.01 KiB]
Downloaded 612 times

Author:  Lusipa [ 21 Jun 2013, 14:38 ]
Post subject:  Re: Plugin development: how-to for newbies

thanks to xenos1984 i finaly became an comand-line-output from my own plugin called "my_plugin.c"

first of all you have to edit the file "navit/CMakeList.txt" (Attention: not "navit/navit/CMakeList.txt"):
In line 374 under the comment "#Modules without test yet" i added:
"add_module(plugin/my_plugin "Default" TRUE)"

Now you need to edit "navit/navit/navit_shipped.xml":
in line 16, somewhere between "<plugin> ...</plugin>" add the line:
<plugin path="$NAVIT_LIBDIR/*/${NAVIT_LIBPREFIX}" active="yes"/>

Now you're able to create your plugin file.
You should store it in the folder "navit/navit/plugin/my_plugin"
here i copied the code from the wikis plugin page

void plugin_register_something_type(){
        printf("\n\nMy Plugin is now plugged!!!\n\n");


you should also create a "" in the same folder, which should look like (derived from "/navit/navit/plugin/pedestrian/
include $(top_srcdir)/
AM_CPPFLAGS = @NAVIT_CFLAGS@ -I$(top_srcdir) -I$(top_srcdir)/navit -DMODULE=plugin_my_plugin
moduleplugin_LTLIBRARIES =
libplugin_my_plugin_la_LDFLAGS=-module -avoid-version @NAVIT_MODULE_LDFLAGS@ #-Wl,--no-undefined

libplugin_my_plugin_la_SOURCES = my_plugin.c

        cp .libs/ ../../android/libs/armeabi
        cp *.xslt ../../xslt

And also a file called "CMakeLists.txt" with following content:
module_add_library(plugin_my_plugin my_plugin.c)

Now we go one folder backwards and adapt there the "navit/navit/plugin/", too:
  SUBDIRS += pedestrian

  SUBDIRS += my_plugin

DIST_SUBDIRS=pedestrian my_plugin

If you build Navit now from the source (with cmake and make) you should get a comand-line output when starting ./navit

Now I'll look for a way how to access my plugin at a certain while navit is running.
... if i new something new, i'll edit this post.
help welcome. thx.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group