yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #03845
Re: How to use a plugin
> Sorry, I'm a complete jackass and still don't understand how this works. Now I have a C/C++ library that I want to use in my InteractionGeometryFunctor. I want to have assess to the library functions in my Ig2Functor. Will adding the following work in extra/SConscript work?
> env.SharedLibrary('CWBoonPlugin',['InteractionGeometryFunctor'],LIBS=env['LIBS']+['nagc_nag'] )
1. You might need to specify LIBPATH additionally (equal to
[INSTALL_DIR]/lib) so that linker finds that lib.
2. Call your source file different than 'InteractionGeometryFunctor'...
the good practice it to use name of the plugin, i.e.
CWBoonPlugin.cpp ;-)
3. You might need CPPPATH=env['CPPPATH']+['INSTALL_DIR/include'] so that
preprocessor finds the lib's header as you include it in your source.
It is the best to run scons with brief=0, then cut&paste the command
line it executes (g++ ....) and experiment with paths and libs until it
compiles. (CPPPATH translates to -Ipath1 -Ipath2, LIBPATH to -Lpath1
-Lpath2, LIBS to -llib1 -llib2, as you probably know)
> The way to compile it according to the manual is:
> gcc driver.c -I[INSTALL_DIR]/include [INSTALL_DIR]/lib/libnagc_nag.so -lpthread -lm
Look pretty standard to me, should be no problem.
> If not, how to do it the other way round? How can I assess in my External Plugin the functions from YADE, i.e., the equivalent of "from yade import *" in python. So, I can assess info like interaction->id1 or state->pos?
Uh, that would be much more complicated; try to go the first way as much
as you can first.
v
Follow ups
References