变量的多重定义 First defined here error

Multiple definition of variable First defined here error

我有这个 c++ 项目,在 .hpp 文件中有 classes 的定义,在 .cpp 文件中有方法的声明。 该项目使用 makefile 来构建和 运行.

程序运行之前没有错误,但是LinkedList没有按我想要的那样运行,所以我完全重写了它。 现在 LinkedList.hpp 包括 class 定义及其方法的声明。 我调整了其他 classes 的方法,以便它们正确使用 LinkedList。

现在在调试程序时出现 multiple definition of, first defined here 错误。

find: ‘lib’: No such file or directory
g++ -std=c++17 -Wall -Wextra -g -Iinclude -o output/main src/Game.o src/Hero.o src/Title.o src/Level.o src/Menu.o src/Entity.o src/Window.o src/main.o src/Map.o src/Object.o -lncurses 
/usr/bin/ld: src/Hero.o:/home/user/projects/project-X-githubClone/projectX/include/Object.hpp:2: multiple definition of `TileTypeStr'; src/Game.o:/home/user/projects/project-X-githubClone/projectX/include/Object.hpp:2: first defined here
/usr/bin/ld: src/Level.o:/home/user/projects/project-X-githubClone/projectX/include/Object.hpp:2: multiple definition of `TileTypeStr'; src/Game.o:/home/user/projects/project-X-githubClone/projectX/include/Object.hpp:2: first defined here
/usr/bin/ld: src/Entity.o:/home/user/projects/project-X-githubClone/projectX/include/Object.hpp:2: multiple definition of `TileTypeStr'; src/Game.o:/home/user/projects/project-X-githubClone/projectX/include/Object.hpp:2: first defined here
/usr/bin/ld: src/Map.o:/home/user/projects/project-X-githubClone/projectX/include/Object.hpp:2: multiple definition of `TileTypeStr'; src/Game.o:/home/user/projects/project-X-githubClone/projectX/include/Object.hpp:2: first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:74: main] Error 1

因此,如果我理解正确,问题是 const char* TileTypeStr[] 的多个定义。 但是为什么当我将该数组的名称更改为 tts 时,错误消息仍然显示为“TileTypeStr 的多个定义”? 为什么如果我在整个项目中注释掉这个数组的唯一 2 个引用(包括它的声明和初始化),错误消息仍然相同?

TileTypeStr[] 毕竟放错了地方,将它移到我需要它的 toString() 方法中,然后 运行 make clean 重新编译所有源文件和 make 构建 main.cpp。 通过 运行 制作而不是重新编译源文件,我被 运行 程序的错误版本卡住了。