Changes between Version 6 and Version 7 of CHowTo/BasicPluginHowto


Ignore:
Timestamp:
08/05/07 22:32:49 (12 years ago)
Author:
rekkanoryo
Comment:

update to help people being bitten by G_GNUC_NULL_TERMINATED

Legend:

Unmodified
Added
Removed
Modified
  • CHowTo/BasicPluginHowto

    v6 v7  
    2525The command above for Debian systems will install only the build dependencies of Pidgin, Finch, and libpurple.  The command shown for Fedora will install all of those, as well as the development headers for libpurple, Finch, and Pidgin.
    2626
    27 Once you have installed these dependencies, download a source tarball.  You will want to use the source tarball that matches the version of Pidgin you are running, as it's generally a good idea to compile against the same version you run your plugins with.
     27Once you have installed these dependencies, download a source tarball.  You will want to use the source tarball that matches the version of Pidgin you are running, as it's generally a good idea to compile against the same version you run your plugins with.  You can, however, safely build a plugin against Pidgin 2.0.0 and run it with any Pidgin version 2.x.y.
    2828
    2929For the purposes of this How-To, we will assume the following:
     
    254254Now that we have a complete plugin source file, we need to compile it.  From `~/development/pidgin-2.0.2/libpurple/plugins`, run `make helloworld.so` (if using Windows, `make -f Makefile.mingw helloworld.dll`).  If you copied and pasted the code correctly, this should compile without incident.  You can move the resulting .so file to `~/.purple/plugins` (move the resulting .dll file to `%APPDATA%\.purple\plugins` on Windows).  Now when you open the Plugins dialog in Pidgin or Finch, the plugin should show up.  When you load it you should see a message pop up.
    255255
     256== Having Trouble Compiling? ==
     257''Note that this section has been added after the initial completion of this document and as such may break continuity with the preceeding sections and the closing section.  Apologies if this makes the document harder to understand.''
     258
     259If you're having trouble compiling and the error messages being spit out reference `G_GNUC_NULL_TERMINATED`, you are compiling against Pidgin and libpurple version 2.1.0 or newer.  In that case, add the following code to your helloworld.c file ''after'' the `#include <glib.h>` directive:
     260{{{
     261#!c
     262#ifndef G_GNUC_NULL_TERMINATED
     263#  if __GNUC__ >= 4
     264#    define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
     265#  else
     266#    define G_GNUC_NULL_TERMINATED
     267#  endif /* __GNUC__ >= 4 */
     268#endif /* G_GNUC_NULL_TERMINATED */
     269}}}
     270
     271This section of preprocessor code is only needed if you're building against version 2.1.0 or newer.  There were some additions to some function prototypes in libpurple to add GCC 4.x's NULL sentinel attribute.  This will cause issues on many platforms, including Windows, if the version of GLib in use is rather old (2.6.x or older).  There is an additional wrinkle to the problem in that only GCC 4.x have this function attribute, so the workaround is a more complex set of preprocessor directives than we'd like.
     272
     273In libpurple we have fixed this internally, and this fix is technically available to plugins built within the Pidgin source tree.  It is not used here, however, because no third-party plugins are able to use this internal fix, and the point of this series of How-To documents is to help budding third-party plugin developers.  These developers will need to include the fix themselves.
     274
     275If you run into this issue in the future installments of this How-To document series, this same snippet of preprocessor code can be added to the later example plugins in the same place.  It should yield the same effect there as it did here.
     276
    256277== Going Beyond Hello, World! ==
    257278Consider C Plugins 101 complete.  We have more to get to in this tutorial series.  See the other documents listed on the [wiki:CHowTo C Plugin How-To].
All information, including names and email addresses, entered onto this website or sent to mailing lists affiliated with this website will be public. Do not post confidential information, especially passwords!