[galib] VS2005 Linker Errors with GARealAllele

anselmop@sc.usp.br anselmop at sc.usp.br
Sun Jan 27 21:05:20 EST 2008


Hi, Steven.


I got a linking error when I mixed linking configurations. For  
example, when I compiled GAlib with a dynamic runtime library and  
tried to compile my application with a static runtime library (or  
vice-versa. I don't remember exactly which of the two cases).

I suggest you check which linking configurations you are using to  
compile both Galib and your application with regards to the runtime  
library. In MSVC you can modify these in the following menu:


Project -> Properties -> Configuration properties -> C/C++ -> Code  
generation ->Runtime library


Good lück


Anselmo



> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sat, 26 Jan 2008 19:04:29 +0000
> From: Steven Bilton <swb04 at doc.ic.ac.uk>
> Subject: [galib] VS2005 Linker Errors with GARealAllele
> To: galib at mit.edu
> Message-ID: <479B843D.7010206 at doc.ic.ac.uk>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Hey,
>
> I'm having issues compiling the library under VS2005 when using the
> GARealAllele. I've read about a few problems that relate to requiring
> casts, but I'm not really sure where they would be needed.
>
> The errors I get are an array of linker errors when including
> GARealGenome.h along the lines of:
>
> 6>GARealGenome.obj : error LNK2005: "public: float __thiscall
> GAAlleleSet<float>::allele(void)const "
> (?allele@?$GAAlleleSet at M@@QBEMXZ) already defined in MyClass.obj
>
> Not including GARealGenome.h of course then causes it to default to the
> definition in GAAllele.C to be used, giving the undefined
> allele(unsigned int) error and breaking it.
>
> At present, it will not compile with the following:
>
> ------------------
>
> #include "ga/MyClass.h"                  // Has no GA related headers
> inside.
> #include "ga/ga.h"
> #include "ga/GARealGenome.h"
> #include "console/console.h"           // Used for other stuff not
> related to GA
> #include "game/shapeBase.h"         // Used for other stuff not related
> to GA
> #include <windows.h>                  // Used for other stuff not
> related to GA
>
> #define INSTANTIATE_REAL_GENOME
>
> float fitnessFunction(GAGenome& g)
> {
>     return 0;
> }
>
> void MyClass::run()
> {
>     GARealAlleleSetArray alleles;
>     alleles.add(0,1);
>     GARealGenome genome(alleles, fitnessFunction);
> }
>
> ------------------
>
> Any pointers appreciated.
>
> Cheers
> Steve
>
>
> ------------------------------





More information about the galib mailing list