[galib] GA problem
Peter Jay Salzman
p at dirac.org
Fri Nov 2 09:46:52 EDT 2007
On Fri 02 Nov 07, 4:43 PM, Somnath Bhattacharjee <sn.bhattacharjee at yahoo.co.in> said:
>
> when I import all the GA Library files and "Build" it, it
> shows (In VC++ 2005 Express Edition)....
>
>
> Creating library...
> GATree.obj : warning LNK4221: no public symbols found; archive member will
> be inaccessible
> GAListGenome.obj : warning LNK4221: no public symbols found; archive
> member will be inaccessible
> GAList.obj : warning LNK4221: no public symbols found; archive member will
> be inaccessible
> GAAllele.obj : warning LNK4221: no public symbols found; archive member
> will be inaccessible
> GA3DArrayGenome.obj : warning LNK4221: no public symbols found; archive
> member will be inaccessible
> GA2DArrayGenome.obj : warning LNK4221: no public symbols found; archive
> member will be inaccessible
> GA1DArrayGenome.obj : warning LNK4221: no public symbols found; archive
> member will be inaccessible
>
> Results
>
> Build log was saved at "file://d:\galib246\project\vcpp2005\ga\Release\BuildLog.htm"
> ga - 0 error(s), 7 warning(s)
>
>
>
>
>
>
>
> Ignoring the warnings when I import an example from the 'examples' given
> with "galib246", then it's showing many errors.I'm sending those
> errors for the example(ex9.cpp) I used.
>
>
>
> With Regards
>
> Somnath
>
>
>
>
>
>
>
> Compiling...
> ex9.cpp
> Compiling manifest to resources...
> Linking...
> ex9.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall GASimpleGA::~GASimpleGA(void)" (??1GASimpleGA@@UAE at XZ) referenced in function _main
> ex9.obj : error LNK2019: unresolved external symbol "public: float __thiscall GABin2DecGenome::phenotype(unsigned int)const " (?phenotype at GABin2DecGenome@@QBEMI at Z) referenced in function _main
> ex9.obj : error LNK2019: unresolved external symbol "public: class GAGenome const & __thiscall GAStatistics::bestIndividual(unsigned int)const " (?bestIndividual at GAStatistics@@QBEABVGAGenome@@I at Z) referenced in function _main
> ex9.obj : error LNK2019: unresolved external symbol "public: virtual int __thiscall GASimpleGA::populationSize(unsigned int)" (?populationSize at GASimpleGA@@UAEHI at Z) referenced in function _main
> ex9.obj : error LNK2001: unresolved external symbol "float gaDefSigmaTruncationMultiplier" (?gaDefSigmaTruncationMultiplier@@3MA)
> ex9.obj : error LNK2019: unresolved external symbol "public: __thiscall GASimpleGA::GASimpleGA(class GAGenome const &)" (??0GASimpleGA@@QAE at ABVGAGenome@@@Z) referenced in function _main
> ex9.obj : error LNK2019: unresolved external symbol "public: void __thiscall GABin2DecPhenotype::add(unsigned int,float,float)" (?add at GABin2DecPhenotype@@QAEXIMM at Z) referenced in function _main
> ex9.obj : error LNK2019: unresolved external symbol "public: float __thiscall GASigmaTruncationScaling::multiplier(float)" (?multiplier at GASigmaTruncationScaling@@QAEMM at Z) referenced in function "public: __thiscall GASigmaTruncationScaling::GASigmaTruncationScaling(float)" (??0GASigmaTruncationScaling@@QAE at M@Z)
> ex9.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall GASigmaTruncationScaling::evaluate(class GAPopulation const &)" (?evaluate at GASigmaTruncationScaling@@UAEXABVGAPopulation@@@Z)
> ex9.obj : error LNK2019: unresolved external symbol "public: void __thiscall GAStatistics::flushScores(void)" (?flushScores at GAStatistics@@QAEXXZ) referenced in function "public: virtual void __thiscall GAGeneticAlgorithm::evolve(unsigned int)" (?evolve at GAGeneticAlgorithm@@UAEXI at Z)
> ex9.obj : error LNK2019: unresolved external symbol "public: int __thiscall GAParameterList::set(char const *,void const *)" (?set at GAParameterList@@QAEHPBDPBX at Z) referenced in function "public: int __thiscall GAParameterList::set(char const *,unsigned int)" (?set at GAParameterList@@QAEHPBDI at Z)
> ex9.obj : error LNK2019: unresolved external symbol "public: int __thiscall GAParameterList::set(char const *,double)" (?set at GAParameterList@@QAEHPBDN at Z) referenced in function "public: float __thiscall GAGeneticAlgorithm::pCrossover(float)" (?pCrossover at GAGeneticAlgorithm@@QAEMM at Z)
> ex9.obj : error LNK2019: unresolved external symbol "public: int __thiscall GAStatistics::flushFrequency(unsigned int)" (?flushFrequency at GAStatistics@@QAEHI at Z) referenced in function "public: int __thiscall GAGeneticAlgorithm::flushFrequency(unsigned int)" (?flushFrequency at GAGeneticAlgorithm@@QAEHI at Z)
> ex9.obj : error LNK2019: unresolved external symbol "public: class GAScalingScheme & __thiscall GAPopulation::scaling(class GAScalingScheme const &)" (?scaling at GAPopulation@@QAEAAVGAScalingScheme@@ABV2@@Z) referenced in function "public: virtual class GAScalingScheme & __thiscall GASimpleGA::scaling(class GAScalingScheme const &)" (?scaling at GASimpleGA@@UAEAAVGAScalingScheme@@ABV2@@Z)
> ex9.obj : error LNK2019: unresolved external symbol "public: __thiscall GABin2DecPhenotypeCore::GABin2DecPhenotypeCore(void)" (??0GABin2DecPhenotypeCore@@QAE at XZ) referenced in function "public: __thiscall GABin2DecPhenotype::GABin2DecPhenotype(void)" (??0GABin2DecPhenotype@@QAE at XZ)
> ex9.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall GA1DBinaryStringGenome::~GA1DBinaryStringGenome(void)" (??1GA1DBinaryStringGenome@@UAE at XZ) referenced in function __unwindfunclet$??0GABin2DecGenome@@QAE at ABVGABin2DecPhenotype@@P6AMAAVGAGenome@@@ZPAX at Z$0
> ex9.obj : error LNK2019: unresolved external symbol "int __cdecl GABinaryDecode(float &,unsigned char const *,unsigned int,float,float)" (?GABinaryDecode@@YAHAAMPBEIMM at Z) referenced in function "public: __thiscall GABin2DecGenome::GABin2DecGenome(class GABin2DecPhenotype const &,float (__cdecl*)(class GAGenome &),void *)" (??0GABin2DecGenome@@QAE at ABVGABin2DecPhenotype@@P6AMAAVGAGenome@@@ZPAX at Z)
> ex9.obj : error LNK2019: unresolved external symbol "int __cdecl GABinaryEncode(float &,unsigned char *,unsigned int,float,float)" (?GABinaryEncode@@YAHAAMPAEIMM at Z) referenced in function "public: __thiscall GABin2DecGenome::GABin2DecGenome(class GABin2DecPhenotype const &,float (__cdecl*)(class GAGenome &),void *)" (??0GABin2DecGenome@@QAE at ABVGABin2DecPhenotype@@P6AMAAVGAGenome@@@ZPAX at Z)
> ex9.obj : error LNK2019: unresolved external symbol "public: static float __cdecl GA1DBinaryStringGenome::BitComparator(class GAGenome const &,class GAGenome const &)" (?BitComparator at GA1DBinaryStringGenome@@SAMABVGAGenome@@0 at Z) referenced in function "public: __thiscall GABin2DecGenome::GABin2DecGenome(class GABin2DecPhenotype const &,float (__cdecl*)(class GAGenome &),void *)" (??0GABin2DecGenome@@QAE at ABVGABin2DecPhenotype@@P6AMAAVGAGenome@@@ZPAX at Z)
> ex9.obj : error LNK2019: unresolved external symbol "public: __thiscall GA1DBinaryStringGenome::GA1DBinaryStringGenome(unsigned int,float (__cdecl*)(class GAGenome &),void *)" (??0GA1DBinaryStringGenome@@QAE at IP6AMAAVGAGenome@@@ZPAX at Z) referenced in function "public: __thiscall GABin2DecGenome::GABin2DecGenome(class GABin2DecPhenotype const &,float (__cdecl*)(class GAGenome &),void *)" (??0GABin2DecGenome@@QAE at ABVGABin2DecPhenotype@@P6AMAAVGAGenome@@@ZPAX at Z)
> ex9.obj : error LNK2001: unresolved external symbol "public: virtual class GAGenome * __thiscall GABin2DecGenome::clone(enum GAGenome::CloneMethod)const " (?clone at GABin2DecGenome@@UBEPAVGAGenome@@W4CloneMethod at 2@@Z)
> ex9.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall GABin2DecGenome::copy(class GAGenome const &)" (?copy at GABin2DecGenome@@UAEXABVGAGenome@@@Z)
> ex9.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall GABin2DecGenome::read(class std::basic_istream > &)" (?read at GABin2DecGenome@@UAEHAAV?$basic_istream at DU?$char_traits at D@std@@@std@@@Z)
> ex9.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall GABin2DecGenome::write(class std::basic_ostream > &)const " (?write at GABin2DecGenome@@UBEHAAV?$basic_ostream at DU?$char_traits at D@std@@@std@@@Z)
> ex9.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall GABin2DecGenome::equal(class GAGenome const &)const " (?equal at GABin2DecGenome@@UBEHABVGAGenome@@@Z)
> ex9.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall GABin2DecGenome::notequal(class GAGenome const &)const " (?notequal at GABin2DecGenome@@UBEHABVGAGenome@@@Z)
> ex9.obj : error LNK2019: unresolved external symbol "public: __thiscall GABin2DecPhenotypeCore::GABin2DecPhenotypeCore(class GABin2DecPhenotypeCore const &)" (??0GABin2DecPhenotypeCore@@QAE at ABV0@@Z) referenced in function "public: __thiscall GABin2DecPhenotype::GABin2DecPhenotype(class GABin2DecPhenotype const &)" (??0GABin2DecPhenotype@@QAE at ABV0@@Z)
> D:\galib246\project\ex9\Debug\ex9.exe : fatal error LNK1120: 27 unresolved externals
>
> Results
>
> Build log was saved at "file://d:\galib246\project\ex9\ex9\Debug\BuildLog.htm"
> ex9 - 28 error(s), 0 warning(s)
>
>
>
> /*
> ----------------------------------------------------------------------------
> ex9.C
> mbwall 10apr95
> Copyright 1995-1996 Massachusetts Institute of Technology
>
> DESCRIPTION:
> Sample program that illustrates how to use a GA to find the maximum
> value
> of a continuous function in two variables. This program uses a binary-to-
> decimal genome.
> ----------------------------------------------------------------------------
> */
> #include <stdio.h>
> #include <ga/ga.h>
> #include <ga/std_stream.h>
>
> #define cout STD_COUT
>
> float objective(GAGenome &);
>
> int
> main(int argc, char **argv)
> {
> cout << "Example 9\n\n";
> cout << "This program finds the maximum value in the function\n";
> cout << " y = - x1^2 - x2^2\n";
> cout << "with the constraints\n";
> cout << " -5 <= x1 <= 5\n";
> cout << " -5 <= x2 <= 5\n";
> cout << "\n\n"; cout.flush();
>
> // See if we've been given a seed to use (for testing purposes). When you
> // specify a random seed, the evolution will be exactly the same each time
> // you use that seed number.
>
> unsigned int seed = 0;
> for(int i=1; i<argc; i++) {
> if(strcmp(argv[i++],"seed") == 0) {
> seed = atoi(argv[i]);
> }
> }
>
> // Declare variables for the GA parameters and set them to some default
> values.
>
> int popsize = 30;
> int ngen = 100;
> float pmut = 0.01;
> float pcross = 0.6;
>
> // Create a phenotype for two variables. The number of bits you can use
> to
> // represent any number is limited by the type of computer you are using.
> In
> // this case, we use 16 bits to represent a floating point number whose
> value
> // can range from -5 to 5, inclusive. The bounds on x1 and x2 can be
> applied
> // here and/or in the objective function.
>
> GABin2DecPhenotype map;
> map.add(16, -5, 5);
> map.add(16, -5, 5);
>
> // Create the template genome using the phenotype map we just made.
>
> GABin2DecGenome genome(map, objective);
>
> // Now create the GA using the genome and run it. We'll use sigma
> truncation
> // scaling so that we can handle negative objective scores.
>
> GASimpleGA ga(genome);
> GASigmaTruncationScaling scaling;
> ga.populationSize(popsize);
> ga.nGenerations(ngen);
> ga.pMutation(pmut);
> ga.pCrossover(pcross);
> ga.scaling(scaling);
> ga.scoreFilename("bog.dat");
> ga.scoreFrequency(10);
> ga.flushFrequency(50);
> ga.evolve(seed);
>
> // Dump the results of the GA to the screen.
>
> genome = ga.statistics().bestIndividual();
> cout << "the ga found an optimum at the point (";
> cout << genome.phenotype(0) << ", " << genome.phenotype(1) << ")\n\n";
> cout << "best of generation data are in '" << ga.scoreFilename() <<
> "'\n";
>
> return 0;
> }
>
> // This objective function tries to maximize the value of the function
> //
> // y = -(x1*x1 + x2*x2)
> //
> float
> objective(GAGenome & c)
> {
> GABin2DecGenome & genome = (GABin2DecGenome &)c;
>
> float y;
> y = -genome.phenotype(0) * genome.phenotype(0);
> y -= genome.phenotype(1) * genome.phenotype(1);
> return y;
> }
Hi Somnath,
I'm not really a Windows programmer, so this is simply a stab in the dark.
Are you SURE you're building this as a LIB? It looks like you're building
this as a DLL. You can do that, but it requires a considerable number of
changes to the non-template class definitions.
If you have your heart set on a DLL, then be prepared for some detective
work. Hint: When you Google, you'll find some highly useful posts, but they
don't mention that you ALSO must import/export the non-member utility
functions too, since they're also symbols to be exposed.
Pete
--
GPG Fingerprint: B9F1 6CF3 47C4 7CD8 D33E 70A9 A3B9 1945 67EA 951D
Last night I dreamt of 09-f9-11-02-9d-74-e3-5b-d8-41-56-c5-63-56-88-c0
"A mathematician is a machine for converting coffee p at dirac.org
into theorems." -- Paul Erdös http://www.dirac.org
More information about the galib
mailing list