Hi,<br><br>I&#39;m working on a raster module written in C and I want to use C++ libraries to build a function but I don&#39;t know anything about linkers. I tried to use &#39;extern &quot;C&quot;&#39; to build the function in  C++ code and declare it in a header file shared by C (the local_proto.h header) but I have no idea if this could work since I haven&#39;t been able to compile. I also tried to modify my makefile in order to compile the C  and the C++ files together but I have little experience on building custom makefiles...<br>
I could rewrite the whole code in C++ but that&#39;s too much work. Any hint or example code? By the way, the C++ library that I&#39;m trying to use is GAlib, a genetic algorithms library.<br><br>This is how C++ function looks like:<br>
<br><i>extern &quot;C&quot; {<br>#include &lt;grass/gis.h&gt;<br>#include &lt;grass/glocale.h&gt;<br>#include &lt;stdio.h&gt;<br>#include &quot;fann.h&quot;<br>#include &quot;local_proto.h&quot;<br>}<br><br>#include &lt;math.h&gt;<br>
<br>#include &lt;ga/GASimpleGA.h&gt;<br>#include &lt;ga/GABin2DecGenome.h&gt;<br>#include &lt;ga/std_stream.h&gt;<br><br>#define cout STD_COUT<br><br><br>extern &quot;C&quot; void genetic(struct input * init, struct layer * vars, struct output * out, char * NNconfig, int totalayers, int rows, int cols, int * fixedcat)<br>
{<br>/*Nothing yet. I have to learn how to compile this*/<br>}<br></i><br>This is my &quot;local_proto.h&quot; file:<br><br><i>#include &lt;grass/gis.h&gt;<br>#include &lt;grass/glocale.h&gt;<br><br><br>struct input<br>{<br>
    const char *name, *mapset;<br>    int fd;<br>    CELL *buf; /**puntero del tipo double CELL**/<br>};<br><br>struct layer<br>{<br>    const char *name, *mapset;<br>    int fd;<br>    DCELL *buf; /**puntero del tipo double CELL**/<br>
};<br><br>struct output<br>{<br>    const char *name, *mapset;<br>    int fd;<br>    CELL *buf;<br>};<br><br><br>/* tfile.c */<br>void Create_training_file(struct input *, struct layer *, int, int, int, int);<br><br>/* simple.c */<br>
void Simple_training(char *, char *, unsigned int, unsigned int, unsigned int, float, unsigned int *);<br><br>/*interpol.c*/<br>double interpolate(struct layer, int, int, int, int);<br><br>/*run.c*/<br>void run_NN(struct input *, struct layer *, struct output *, char *, int, int, int, int *);<br>
<br>/*genetic_fann.cc*/<br><br>#ifdef __cplusplus<br>extern &quot;C&quot;<br>#endif<br>void genetic(struct input *, struct layer *, struct output *, char *, int, int, int, int *);<br></i><br>And my makefile (pretty much standard):<br>
<i><br>MODULE_TOPDIR = ../..<br><br><br>PGM = r.ailucc<br><br><br>LIBES = $(STATSLIB) $(RASTERLIB) $(GISLIB) <br>DEPENDENCIES = $(STATSDEP) $(RASTERDEP) $(GISDEP)<br><br>include $(MODULE_TOPDIR)/include/Make/Module.make<br>
<br>LDFLAGS+= -lfann <br><br><br>default: cmd<br></i><br><br><br><br><br>