CGLemon / Sayuri

AlphaZero based engine for the game of Go (圍棋/围棋).
GNU General Public License v3.0
89 stars 11 forks source link

debian编译不了 #3

Open Saturday-morning opened 1 year ago

Saturday-morning commented 1 year ago

我是Debian11,这是 执行 make 的时候的报错:

In file included from /home/suerya/工程/Sayuri/src/pattern/gammas_dict.cc:1:
/home/suerya/工程/Sayuri/src/pattern/pattern.h:14:13: error: uint64_t’ in namespace ‘std’ does not name a type
   14 | extern std::uint64_t PatternHash[8][4][kMaxPatternArea];
      |             ^~~~~~~~
In file included from /home/suerya/工程/Sayuri/src/pattern/gammas_dict.cc:2:
/home/suerya/工程/Sayuri/src/pattern/gammas_dict.h:9:26: error: std::string’ has not been declared
    9 |     void Initialize(std::string filename);
      |                          ^~~~~~
/home/suerya/工程/Sayuri/src/pattern/gammas_dict.h:11:28: error: std::uint64_t’ has not been declared
   11 |     bool ProbePattern(std::uint64_t hash, float &val) const;
      |                            ^~~~~~~~
/home/suerya/工程/Sayuri/src/pattern/gammas_dict.h:12:28: error: std::uint64_t’ has not been declared
   12 |     bool ProbeFeature(std::uint64_t hash, float &val) const;
      |                            ^~~~~~~~
/home/suerya/工程/Sayuri/src/pattern/gammas_dict.h:15:29: error: std::uint64_t’ has not been declared
   15 |     bool InsertPattern(std::uint64_t hash, float val);
      |                             ^~~~~~~~
/home/suerya/工程/Sayuri/src/pattern/gammas_dict.h:16:29: error: std::uint64_t’ has not been declared
   16 |     bool InsertFeature(std::uint64_t hash, float val);
      |                             ^~~~~~~~
/home/suerya/工程/Sayuri/src/pattern/gammas_dict.h:18:29: error: uint64_t’ is not a member of ‘std’
   18 |     std::unordered_map<std::uint64_t, float> pattern_dict_;
      |                             ^~~~~~~~
/home/suerya/工程/Sayuri/src/pattern/gammas_dict.h:18:29: error: uint64_t’ is not a member of ‘std/home/suerya/工程/Sayuri/src/pattern/gammas_dict.h:18:44: error: template argument 1 is invalid
   18 |     std::unordered_map<std::uint64_t, float> pattern_dict_;
      |                                            ^
/home/suerya/工程/Sayuri/src/pattern/gammas_dict.h:18:44: error: template argument 3 is invalid
/home/suerya/工程/Sayuri/src/pattern/gammas_dict.h:18:44: error: template argument 4 is invalid
/home/suerya/工程/Sayuri/src/pattern/gammas_dict.h:18:44: error: template argument 5 is invalid
/home/suerya/工程/Sayuri/src/pattern/gammas_dict.h:19:29: error: uint64_t’ is not a member of ‘std’
   19 |     std::unordered_map<std::uint64_t, float> feature_dict_;
      |                             ^~~~~~~~
/home/suerya/工程/Sayuri/src/pattern/gammas_dict.h:19:29: error: uint64_t’ is not a member of ‘std/home/suerya/工程/Sayuri/src/pattern/gammas_dict.h:19:44: error: template argument 1 is invalid
   19 |     std::unordered_map<std::uint64_t, float> feature_dict_;
      |                                            ^
/home/suerya/工程/Sayuri/src/pattern/gammas_dict.h:19:44: error: template argument 3 is invalid
/home/suerya/工程/Sayuri/src/pattern/gammas_dict.h:19:44: error: template argument 4 is invalid
/home/suerya/工程/Sayuri/src/pattern/gammas_dict.h:19:44: error: template argument 5 is invalid
/home/suerya/工程/Sayuri/src/pattern/gammas_dict.cc:15:6: error: no declaration matches ‘void GammasDict::Initialize(std::string)’
   15 | void GammasDict::Initialize(std::string filename) {
      |      ^~~~~~~~~~
In file included from /home/suerya/工程/Sayuri/src/pattern/gammas_dict.cc:2:
/home/suerya/工程/Sayuri/src/pattern/gammas_dict.h:9:10: note: candidate is: ‘void GammasDict::Initialize(int)’
    9 |     void Initialize(std::string filename);
      |          ^~~~~~~~~~
/home/suerya/工程/Sayuri/src/pattern/gammas_dict.h:5:7: note: class GammasDict’ defined here
    5 | class GammasDict {
      |       ^~~~~~~~~~
/home/suerya/工程/Sayuri/src/pattern/gammas_dict.cc:73:6: error: no declaration matches ‘bool GammasDict::ProbePattern(uint64_t, float&) const’
   73 | bool GammasDict::ProbePattern(std::uint64_t hash, float &val) const {
      |      ^~~~~~~~~~
In file included from /home/suerya/工程/Sayuri/src/pattern/gammas_dict.cc:2:
/home/suerya/工程/Sayuri/src/pattern/gammas_dict.h:11:10: note: candidate is: ‘bool GammasDict::ProbePattern(int, float&) const’
   11 |     bool ProbePattern(std::uint64_t hash, float &val) const;
      |          ^~~~~~~~~~~~
/home/suerya/工程/Sayuri/src/pattern/gammas_dict.h:5:7: note: class GammasDict’ defined here
    5 | class GammasDict {
      |       ^~~~~~~~~~
/home/suerya/工程/Sayuri/src/pattern/gammas_dict.cc:82:6: error: no declaration matches ‘bool GammasDict::ProbeFeature(uint64_t, float&) const’
   82 | bool GammasDict::ProbeFeature(std::uint64_t hash, float &val) const {
      |      ^~~~~~~~~~
In file included from /home/suerya/工程/Sayuri/src/pattern/gammas_dict.cc:2:
/home/suerya/工程/Sayuri/src/pattern/gammas_dict.h:12:10: note: candidate is: ‘bool GammasDict::ProbeFeature(int, float&) const’
   12 |     bool ProbeFeature(std::uint64_t hash, float &val) const;
      |          ^~~~~~~~~~~~
/home/suerya/工程/Sayuri/src/pattern/gammas_dict.h:5:7: note: class GammasDict’ defined here
    5 | class GammasDict {
      |       ^~~~~~~~~~
/home/suerya/工程/Sayuri/src/pattern/gammas_dict.cc:91:6: error: no declaration matches ‘bool GammasDict::InsertPattern(uint64_t, float)’
   91 | bool GammasDict::InsertPattern(std::uint64_t hash, float val) {
      |      ^~~~~~~~~~
In file included from /home/suerya/工程/Sayuri/src/pattern/gammas_dict.cc:2:
/home/suerya/工程/Sayuri/src/pattern/gammas_dict.h:15:10: note: candidate is: ‘bool GammasDict::InsertPattern(int, float)’
   15 |     bool InsertPattern(std::uint64_t hash, float val);
      |          ^~~~~~~~~~~~~
/home/suerya/工程/Sayuri/src/pattern/gammas_dict.h:5:7: note: class GammasDict’ defined here
    5 | class GammasDict {
      |       ^~~~~~~~~~
/home/suerya/工程/Sayuri/src/pattern/gammas_dict.cc:100:6: error: no declaration matches ‘bool GammasDict::InsertFeature(uint64_t, float)’
  100 | bool GammasDict::InsertFeature(std::uint64_t hash, float val) {
      |      ^~~~~~~~~~
In file included from /home/suerya/工程/Sayuri/src/pattern/gammas_dict.cc:2:
/home/suerya/工程/Sayuri/src/pattern/gammas_dict.h:16:10: note: candidate is: ‘bool GammasDict::InsertFeature(int, float)’
   16 |     bool InsertFeature(std::uint64_t hash, float val);
      |          ^~~~~~~~~~~~~
/home/suerya/工程/Sayuri/src/pattern/gammas_dict.h:5:7: note: class GammasDict’ defined here
    5 | class GammasDict {

是这个系统不满足什么需求吗?debian和ubuntu之间的什么差距才会导致这个问题发生呢?

CGLemon commented 1 year ago

不好意思,這是我的問題,由於少了一些 header file ,導致不同版本的 gcc 可能編譯不過。請在 src/pattern/gammas_dict.h 檔案中加入以下的 header file

#pragma once

#include <unordered_map>
#include <string>  // 加入的 header file
#include <cstdint> // 加入的 header file

class GammasDict {
    ......
};

如果成功編譯或是有其它問題的話,請通知我,謝謝!

Saturday-morning commented 1 year ago

非常感谢你的答复! 现在变成了这样:

In file included from /home/suerya/工程/Sayuri/src/pattern/gammas_dict.cc:1:
/home/suerya/工程/Sayuri/src/pattern/pattern.h:14:13: error: uint64_t’ in namespace ‘std’ does not name a type
   14 | extern std::uint64_t PatternHash[8][4][kMaxPatternArea];
      |             ^~~~~~~~
/home/suerya/工程/Sayuri/src/pattern/gammas_dict.cc: In member function ‘void GammasDict::Initialize(std::string)’:
/home/suerya/工程/Sayuri/src/pattern/gammas_dict.cc:59:38: error: PatternHash’ was not declared in this scope
   59 |                 std::uint64_t hash = PatternHash[0][kInvalid][0];
      |                                      ^~~~~~~~~~~
make[2]: *** [CMakeFiles/Sayuri.dir/build.make:290:CMakeFiles/Sayuri.dir/src/pattern/gammas_dict.cc.o] 错误 1
make[1]: *** [CMakeFiles/Makefile2:95:CMakeFiles/Sayuri.dir/all] 错误 2
make: *** [Makefile:103:all] 错误 2
CGLemon commented 1 year ago

請在 src/pattern/pattern.h 檔案中加入以下的 header file

#pragma once

#include <array>
#include <cstdint> // 加入的 header file

void PatternHashAndCoordsInit();
int CharToColor(char s);

static constexpr int kMaxPatternDist = 10;
static constexpr int kMaxPatternArea = kMaxPatternDist * kMaxPatternDist;

struct PtCoord { int x, y; };
extern std::array<PtCoord, kMaxPatternArea> kPointCoords;
extern std::array<int, kMaxPatternDist + 2> kPointIndex;
extern std::uint64_t PatternHash[8][4][kMaxPatternArea];
Saturday-morning commented 1 year ago

编译成功了!!congratulation!

CGLemon commented 1 year ago

感謝你的幫助!晚點我會推送修正過的版本