Difference between revisions of "Third party plugins"

From Yade

 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
  +
#REDIRECT [[Adding external library dependency]]
 
[[Category:Developer guide]]
 
[[Category:Developer guide]]
If your plugin does not build with scons, you can use [http://pkgconfig.freedesktop.org pkg-config] to compile it. If you installed yade from debian packages, you have file <tt>/usr/lib/pkgconfig/yade-svn1144.pc</tt> (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 <code>pkg</code>, <code>lib</code> and <code>extra</code> - for example <code>Box</code>, <code>AABB</code> and <code>InteractingBox</code>.
 
** exclude core classes (<code>Omega</code>, <code>Body</code> -- <code>#include<yade/core/Something.hpp></code>), 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:
 
<pre> $ 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
 
</pre>
 
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 <tt>~/.yade-svn1144/preferences.xml</tt>, add path to <tt>libmyPlugin1.so</tt> (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.
 

Latest revision as of 20:09, 3 November 2009