简体   繁体   English

NEAT C ++编译器错误Microsoft Visual Studio 2012

[英]NEAT C++ Compiler errors Microsoft Visual Studio 2012

I would like to run the following C++ library (from 2010) under Microsoft Visual Studio 2012: 我想在Microsoft Visual Studio 2012下运行以下C ++库(从2010开始):

http://nn.cs.utexas.edu/?neat-c http://nn.cs.utexas.edu/?neat-c

I already fixed a lot of compiler errors, but for some issues I find no solution. 我已经修复了很多编译器错误,但是对于某些问题,我找不到解决方案。 The compiler errors are: 编译器错误是:

1>------ Build started: Project: My_Neuronal_Network, Configuration: Debug Win32 ------
1>  species.cpp
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\species.cpp(454): warning C4101: 'spin' : unreferenced local variable
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\species.cpp(433): warning C4101: 'pause' : unreferenced local variable
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\species.cpp(453): warning C4101: 'marble' : unreferenced local variable
1>  population.cpp
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\population.cpp(71): warning C4101: 'count' : unreferenced local variable
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\population.cpp(432): warning C4101: 'pause' : unreferenced local variable
1>  genome.cpp
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(1777): warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(1790): warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(1795): warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(1845): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(1862): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(1884): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(1888): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(1961): warning C4101: 'p1innov' : unreferenced local variable
1>  experiments.cpp
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(52): error C2057: expected constant expression
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(52): error C2466: cannot allocate an array of constant size 0
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(52): error C2133: 'evals' : unknown size
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(53): error C2057: expected constant expression
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(53): error C2466: cannot allocate an array of constant size 0
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(53): error C2133: 'genes' : unknown size
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(54): error C2057: expected constant expression
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(54): error C2466: cannot allocate an array of constant size 0
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(54): error C2133: 'nodes' : unknown size
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(316): error C2057: expected constant expression
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(316): error C2466: cannot allocate an array of constant size 0
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(316): error C2133: 'runs' : unknown size
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(512): error C3861: 'lrand48': identifier not found
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(513): error C3861: 'lrand48': identifier not found
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(514): error C3861: 'lrand48': identifier not found
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(515): error C3861: 'lrand48': identifier not found
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(573): warning C4305: 'initializing' : truncation from 'double' to 'const float'
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(575): warning C4305: 'initializing' : truncation from 'double' to 'const float'
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(580): warning C4305: 'initializing' : truncation from 'double' to 'const float'
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(581): warning C4305: 'initializing' : truncation from 'double' to 'const float'
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(623): error C2057: expected constant expression
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(623): error C2466: cannot allocate an array of constant size 0
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(623): error C2133: 'record' : unknown size
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(625): error C2057: expected constant expression
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(625): error C2466: cannot allocate an array of constant size 0
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(625): error C2133: 'genesrec' : unknown size
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(627): error C2057: expected constant expression
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(627): error C2466: cannot allocate an array of constant size 0
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(627): error C2133: 'nodesrec' : unknown size
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(629): error C2057: expected constant expression
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(629): error C2466: cannot allocate an array of constant size 0
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(629): error C2133: 'winnergens' : unknown size
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(692): warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\experiments.cpp(706): warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
1>  Generating Code...
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(543): error C4703: potentially uninitialized local pointer variable 'bias' used
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(1948): error C4703: potentially uninitialized local pointer variable 'newgene' used
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(1533): error C4703: potentially uninitialized local pointer variable 'newnode' used
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(1777): error C4703: potentially uninitialized local pointer variable 'nodep1' used
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(1777): error C4703: potentially uninitialized local pointer variable 'nodep2' used
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(1808): error C4703: potentially uninitialized local pointer variable 'newgene' used
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(1531): error C4703: potentially uninitialized local pointer variable 'newgene1' used
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(1532): error C4703: potentially uninitialized local pointer variable 'newgene2' used
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(2500): error C4703: potentially uninitialized local pointer variable 'chosengene' used
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(2151): error C4703: potentially uninitialized local pointer variable 'chosengene' used
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\genome.cpp(2794): error C4703: potentially uninitialized local pointer variable 'chosengene' used
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\population.cpp(90): error C4703: potentially uninitialized local pointer variable 'new_genome' used
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\population.cpp(289): error C4703: potentially uninitialized local pointer variable 'new_genome' used
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\population.cpp(546): error C4703: potentially uninitialized local pointer variable 'best_species' used
1>c:\users\sebi\desktop\neuroevolution\neat.1.2.1\neat.1.2.1\species.cpp(89): error C4703: potentially uninitialized local pointer variable 'thechamp' used
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

In neat.cpp there is the following defined: 在neat.cpp中,定义了以下内容:

%neat.cpp
...
int NEAT::num_runs = 1;
...

The first error occurs then at: 然后,第一个错误发生在:

%experiments.cpp
 int evals[NEAT::num_runs];  //Hold records for each run 

So somehow this value is not constant. 因此,该值不是恒定的。 I changes nothing at all if I use const int NEAT::num_runs=1; 如果我使用const int NEAT :: num_runs = 1,我什么也不会改变。

Has Someone already used this library and was able to run this under visual studio? 有人使用过这个库并且能够在Visual Studio中运行它吗?

Best Regards Sebi 最好的问候塞比

Essential errors 基本错误

error C4703: potentially uninitialized local pointer variable

this error solved just by initialing variable with NULL . 只需使用NULL初始化变量即可解决此错误。 But actually it is not an error, it is warning and it might be turned off in project settings. 但是实际上这不是错误,它是警告,可能在项目设置中已关闭。

Error occurs in genome.cpp, population.cpp, species.cpp 错误发生在genome.cpp, population.cpp, species.cpp

So C4703 is only error in essential part of NEAT implementation, which means it might be easily compiled with Visual C++. 因此,C4703仅是NEAT实现中必不可少的错误,这意味着它可以使用Visual C ++轻松编译。

Other errors occurs in usage of NEAT for solving pole-balancing tasks. 使用NEAT解决极平衡任务时会发生其他错误。 They might be treated just as examples of usage NEAT. 它们可能仅被视为用法NEAT的示例。

Has Someone already used this library and was able to run this under visual studio? 有人使用过这个库并且能够在Visual Studio中运行它吗?

I have extracted NEAT to static link library which can be used in other Visual Studio projects. 我已经将NEAT提取到静态链接库中,该库可以在其他Visual Studio项目中使用。 And there is second project in solution as example of usage NEAT.lib 解决方案中还有第二个项目,例如用法NEAT.lib

You can check my solution here 你可以在这里检查我的解决方案

Not essential errors 不是本质错误

error C3861: 'lrand48': identifier not found

Just use rand() in VisualC++. 只需在VisualC ++中使用rand()。

error C2133: 'evals' : unknown size

int evals[NEAT::num_runs]; - you can use this in Visual C++ only if NEAT::num_runs is const . -仅当NEAT::num_runsconst才可以在Visual C ++中使用它。 Value of num_runs must be known for compiler. 编译器必须知道num_runs值。

int *evalsPtr = new int[NEAT::num_runs]; - in other case use this -在其他情况下使用此

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM