gpt4 book ai didi

c++ - 使用 GAlib 模板实例化的 Cygwin gcc 编译器问题

转载 作者:行者123 更新时间:2023-11-30 02:52:30 25 4
gpt4 key购买 nike

所有,我在 Win 7 pro x64 上使用 Cygwin gcc 4.8.1 和 Netbeans 7.3.1。我尝试构建 GAlib 项目但遇到模板实例化问题:

g++ -g -Wall -I.. -c ex17.C
../ga/GA2DArrayGenome.C: In instantiation of ‘GA2DArrayAlleleGenome<T>::GA2DArrayAlleleGenome(unsigned int, unsigned int, const GAAlleleSet<T>&, GAGenome::Evaluator, void*) [with T = int; GAGenome::Evaluator = float (*)(GAGenome&)]’:
In file included from ../ga/GA2DArrayGenome.h:150:0,
from ../ga/ga.h:168,
from ex17.C:13:
ex17.C:45:63: required from here
../ga/GA2DArrayGenome.C:272:75: error: ‘initializer’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
initializer(GA2DArrayAlleleGenome<T>::DEFAULT_2DARRAY_ALLELE_INITIALIZER);
^
../ga/GA2DArrayGenome.C:272:75: note: declarations in dependent base ‘GAGenome’ are not found by unqualified lookup
../ga/GA2DArrayGenome.C:272:75: note: use ‘this->initializer’ instead
../ga/GA2DArrayGenome.C:273:67: error: ‘mutator’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
mutator(GA2DArrayAlleleGenome<T>::DEFAULT_2DARRAY_ALLELE_MUTATOR);
^
../ga/GA2DArrayGenome.C:273:67: note: declarations in dependent base ‘GAGenome’ are not found by unqualified lookup
../ga/GA2DArrayGenome.C:273:67: note: use ‘this->mutator’ instead
../ga/GA2DArrayGenome.C:274:73: error: ‘comparator’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
comparator(GA2DArrayAlleleGenome<T>::DEFAULT_2DARRAY_ALLELE_COMPARATOR);
^
../ga/GA2DArrayGenome.C:274:73: note: declarations in dependent base ‘GAGenome’ are not found by unqualified lookup
../ga/GA2DArrayGenome.C:274:73: note: use ‘this->comparator’ instead
../ga/GA2DArrayGenome.C:275:71: error: ‘crossover’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
crossover(GA2DArrayAlleleGenome<T>::DEFAULT_2DARRAY_ALLELE_CROSSOVER);
^
../ga/GA2DArrayGenome.C:275:71: note: declarations in dependent base ‘GAGenome’ are not found by unqualified lookup
../ga/GA2DArrayGenome.C:275:71: note: use ‘this->crossover’ instead
../ga/GA2DArrayGenome.C: In instantiation of ‘GA2DArrayAlleleGenome<T>::GA2DArrayAlleleGenome(unsigned int, unsigned int, const GAAlleleSetArray<T>&, GAGenome::Evaluator, void*) [with T = int; GAGenome::Evaluator = float (*)(GAGenome&)]’:
ex17.C:138:28: required from here
../ga/GA2DArrayGenome.C:289:75: error: ‘initializer’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
initializer(GA2DArrayAlleleGenome<T>::DEFAULT_2DARRAY_ALLELE_INITIALIZER);
^
../ga/GA2DArrayGenome.C:289:75: note: declarations in dependent base ‘GAGenome’ are not found by unqualified lookup
../ga/GA2DArrayGenome.C:289:75: note: use ‘this->initializer’ instead
../ga/GA2DArrayGenome.C:290:67: error: ‘mutator’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
mutator(GA2DArrayAlleleGenome<T>::DEFAULT_2DARRAY_ALLELE_MUTATOR);
^
../ga/GA2DArrayGenome.C:290:67: note: declarations in dependent base ‘GAGenome’ are not found by unqualified lookup
../ga/GA2DArrayGenome.C:290:67: note: use ‘this->mutator’ instead
../ga/GA2DArrayGenome.C:291:73: error: ‘comparator’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
comparator(GA2DArrayAlleleGenome<T>::DEFAULT_2DARRAY_ALLELE_COMPARATOR);
^
../ga/GA2DArrayGenome.C:291:73: note: declarations in dependent base ‘GAGenome’ are not found by unqualified lookup
../ga/GA2DArrayGenome.C:291:73: note: use ‘this->comparator’ instead
../ga/GA2DArrayGenome.C:292:71: error: ‘crossover’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
crossover(GA2DArrayAlleleGenome<T>::DEFAULT_2DARRAY_ALLELE_CROSSOVER);
^
../ga/GA2DArrayGenome.C:292:71: note: declarations in dependent base ‘GAGenome’ are not found by unqualified lookup
../ga/GA2DArrayGenome.C:292:71: note: use ‘this->crossover’ instead
makefile:27: recipe for target `ex17.o' failed
make[1]: *** [ex17.o] Error 1
make[1]: Leaving directory `/cygdrive/c/Users/Daiyue/Documents/NetBeansProjects/galib247/examples'
Makefile:19: recipe for target `ex' failed
make: *** [ex] Error 2

我还在 gaconfig.h 中定义了 NO_AUTO_INST,但错误仍然存​​在。那么如何解决这个问题呢?

干杯

最佳答案

你想要

g++ -g -Wall -I.. -c ex17.C

成为

g++ -g -fpermissive -Wall -I.. -c ex17.C

我编译了 galib ( http://lancet.mit.edu/ga/dist/galib247.tgz ),它也在 ex17.C 编译时停止,同样使用 g++ 4.8.1 版。 Cygwin 就像 linux 的工具一样,所以在顶层源目录中是文件 makevars(不是 makevars.bcc 也不是 makevars.vcpp)。在 makevars 中,更改下面已经取消注释的行

# gcc3, gcc4
#
#
CXXFLAGS = -g -Wall

CXXFLAGS    = -g -fpermissive -Wall

您可能没有在 cygwin 中运行 X,但我也将它放在 examples/graphic/makefile 中并将 wigdet 设置也更改为 athena,并为小部件 header 安装了 libxaw7-dev 包

关于c++ - 使用 GAlib 模板实例化的 Cygwin gcc 编译器问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18838522/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com