Third party plugins

From Yade

Revision as of 22:18, 25 June 2007 by Janek Kozicki (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

If your plugin does not build with scons, you can use pkg-config to compile it. If you installed yade from debian packages, you have file /usr/lib/pkgconfig/yade-svn1144.pc (path will be different from scons installation, see pkg-configu documentation on how to specify path to the .pc file). Using for plugin compilation is as follows:

  • Find out what libraries you need to link with
    • rule of thumb: link against all plugins of which headers you include from pkg, lib and extra - for example Box, AABB and InteractingBox.
    • exclude core classes (Omega, Body -- #include<yade/core/Something.hpp>), their symbols are defined in yade's executable, you cannot link against them directly.
  • Pkg-config will provide you all remaining flags for linker and compiler: you can try yourself that it works:
 $ pkg-config --cflags yade-svn1144 # flags for compiler
-O2 -O3 -ffast-math -pipe -Wall -DLOG4CXX -DEMBED_PYTHON -DSUFFIX="-svn1144" -DPREFIX="/usr" -DYADE_CAST=static_cast -DYADE_PTR_CAST=static_pointer_cast -I/usr/include/yade-svn1144 -I/usr/include/yade-svn1144/yade/lib-miniWm3 -I/usr/share/qt3/include -I/usr/include/python2.5
 $ pkg-config --libs yade-svn1144 # flags for linker
-Wl,-rpath=/usr/lib/yade-svn1144/lib -Wl,-rpath=/usr/lib/yade-svn1144/pkg-common -Wl,-rpath=/usr/lib/yade-svn1144/pkg-dem -Wl,-rpath=/usr/lib/yade-svn1144/pkg-fem -Wl,-rpath=/usr/lib/yade-svn1144/pkg-mass-spring -Wl,-rpath=/usr/lib/yade-svn1144/extra -Wl,-rpath=/usr/lib/yade-svn1144/gui -Xlinker -export-dynamic -rdynamic -shared -L. -L/usr/share/qt3/lib -L/usr/lib/yade-svn1144/lib -L/usr/lib/yade-svn1144/pkg-common -L/usr/lib/yade-svn1144/pkg-dem -L/usr/lib/yade-svn1144/pkg-fem -L/usr/lib/yade-svn1144/pkg-mass-spring -L/usr/lib/yade-svn1144/extra -L/usr/lib/yade-svn1144/gui -lpython2.5

Note that this will ensure consistency between header and library versions.

  • Compile your plugin like this:
g++ `pkg-config --cflags --libs yade-svn1145` MyPluginForYade.cpp -o MyPluginForYade -lAABB -lBox -lShop
  • Edit the file ~/.yade-svn1144/preferences.xml, add path to libmyPlugin1.so (suppose it is /home/fred/prog/yade) to dynLibDirectories:
<Yade>
 <preferences _className_="Preferences"  version="1" dynlibDirectories="[/usr/lib/yade-svn1144/extra /usr/lib/yade-svn1144/gui /usr/lib/yade-svn1144/lib /usr/lib/yade-svn1144/pkg-common /usr/lib/yade-svn1144/pkg-dem /usr/lib/yade-svn1144/pkg-fem /usr/lib/yade-svn1144/pkg-lattice /home/fred/prog/yade]" includeDirectories="[]" defaultGUILibName="QtGUI" />
</Yade>
  • Run yade, it should load your plugin now.

Warning: if you load this plugin with different version of yade, yade will not stop you and it will very likely crash.