Nemo  2.3.56
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
Building and linking your project with Nemo

Once you have finished defining your additional elements, you have to link them with the framework to be able to use them in a simulation run. For that, you will have to actually write a real program (or modify the existing one). Therefore, you have to add a main() function somewhere in your code, compile it and link it against the nemo framework.

Here is how to write the main() function (in a main.cpp file):

#include "simulation.h"
#include "metapop.h"
#include "simenv.h"
#include "mytrait.h"
#include "mylce.h"
int main ( int argc, char **argv )
{
Metapop thePop;
//create a new SimRunner that will run the sim:
SimRunner *theSim = SIMenv::setMainSim( &thePop );
//attach your elements, the trait prototypes to the trait container:
theSim->add_trait( new MyTraitProto() );
//add the LCE to the LCE container:
theSim->add_LCE( new MyLce() );
//that's it, the simulation is ready to run!
if( !theSim->run(argc, argv) ) fatal( " could not run the sim !\n" );
//cleaning before quitting
delete theSim;
return 0;
}
void add_LCE(LifeCycleEvent *event)
Add a life cycle event to the template and component lists.
Definition: basicsimulation.h:58
void add_trait(TraitPrototype *trait)
Add a trait prototype to the template and component lists.
Definition: basicsimulation.h:56
Top class of the metapopulation structure, contains the patches.
Definition: metapop.h:80
static SimRunner * setMainSim(Metapop *pop)
Definition: simenv.h:46
Performs the setup of the Metapop and SimComponents and runs the simulation.
Definition: simulation.h:53
bool run(int ARGC, char **ARGV)
First loop of the simulation, performs the simulations stored in the ParamManager base class.
Definition: simulation.cc:345
int main(int argc, char **argv)
Definition: main.cc:39
void fatal(const char *str,...)
Definition: output.cc:96

Compile and link your project:

g++ -O3 -c mytrait.cpp -o mytrait.o
g++ -O3 -c mylce.cpp -o mylce.o
g++ -O3 -c main.cpp -o main.o
g++ -o myprogram-1.0 mytrait.o mylce.o main.o -lstdc++ -lnemo2.0

The commands above assume that the library libnemo2.0.dylib (or .so, or .dll, depending on the system) is on your path. Otherwise, give the path to the library with the -L option before -lnemo2.0 like this: g++ -o myprogram-1.0 ... -Lnemo-2.0/lib/ -lnemo2.0

Please have a look at the Makefile provided with the code release for more details.

<<prev | –t o p–


Generated for Nemo v2.3.56 by  doxygen 1.9.0 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR