yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #03846
Re: How to use a plugin
Thanks, so much. Does doing this, mean that my file CWBoonPlugin.cpp will have assess to both YADE functions like interaction->id1 and state->pos, as well as the external C library? In other words, behave like any other Ig2Functor?
Another question is this:
The subroutine for the library is Minimize(a,b,C). C is again another subroutine C(x,y,z), which returns the value of the function and its derivatives. I cannot pass YADE pointers to it, because I cannot define C as C(x,y,z, yade pointer). I managed to do it in python by using "from yade import *". This way, I can assess O.bodies.state.pos any place I like within the subroutine, without giving it as the input argument. But the python one is running too slow. How do I do that in C/C++. The equivalent of "from yade import *"?
Thanks,
Boon
----------------------------------------
> From: eudoxos@xxxxxxxx
> To: yade-dev@xxxxxxxxxxxxxxxxxxx
> Date: Mon, 5 Apr 2010 15:28:20 +0200
> Subject: Re: [Yade-dev] 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
>
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-dev
> Post to : yade-dev@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~yade-dev
> More help : https://help.launchpad.net/ListHelp
_________________________________________________________________
Hotmail: Trusted email with powerful SPAM protection.
https://signup.live.com/signup.aspx?id=60969
Follow ups
References