【发布时间】:2013-04-20 04:57:03
【问题描述】:
我一直在尝试让我从学校服务器下载的程序在我的 Mac 上离线运行。我尝试按照教程更新 GCC,但由于某种原因,即使我使用了给出的命令,这些教程也无法正常工作。
现在当我编译时..我收到一个错误说找不到..我不明白。我已经更新了 Xcode.. 遵循了大量的教程.. 我仍然无法运行它!
为什么说random is not found,导致致命错误?
谢谢
错误:
DungeonLevel.h:6:10: fatal error: 'random' file not found
“由于这是一个编码站点,我需要提供代码,因为我可能忘记包含头文件......”
#ifndef _DungeonLevel_included_
#define _DungeonLevel_included_
#include "Tile.h"
#include <vector>
#include <random>
class Player;
class DungeonLevel {
public:
DungeonLevel(int iWidth, int iHeight, std::mt19937 & randomGen);
~DungeonLevel(void);
void dump();
char at(int x, int y);
Creature * removeCreature(Creature * creatureToRemove);
void moveCreature(Creature * creatureToMove, char dir);
void placeInGame(Creature * creatureToPlace, std::mt19937 & randomGen);
void placeInGame(Creature & creatureToPlace, std::mt19937 & randomGen);
Tile & returnTile(int x,int y);
int getWidth();
int getHeight();
private:
std::vector<std::vector<Tile>> m_vvTiles; //Tile was char
};
#endif
这是我的生成文件:
OBJECTS = Ammunition.o Armor.o Consumable.o Creature.o Entity.o Gold.o Item.o parser.o Potion.o Scroll.o Weapon.o XMLSerializable.o CreatureFactory.o DungeonLevel.o Player.o Tile.o ItemFactory.o
HEADERS = Ammunition.h Armor.h Consumable.h Creature.h Entity.h Gold.h Item.h parser.h Potion.h Scroll.h Weapon.h XMLSerializable.h CreatureFactory.h DungeonLevel.h Player.h Tile.h ItemFactory.h
all: Jhack
%.o: %.cpp $(HEADERS)
clang++ -c $< -o $@ -std=c++11 -stdlib=libc++
Jhack: $(OBJECTS) main.o
clang++ -o Jhack $^ -stdlib=libc++
clean:
rm -f *.o Jhack
run: Jhack
./Jhack
【问题讨论】:
-
大声笑,我显然没有忘记包含。同样的代码通过 SSH 也能正常工作。但我还是会发布代码
-
如果我们知道它报告丢失了哪个文件,那就太好了。
-
有 83 个文件。它包含在其中的几个中。第一次遇到...致命错误
-
我认为查看您遇到的 full、actual 错误会很有帮助。
-
<random>是在 C++11 中引入的。您使用的是旧版本的 GCC,或者您没有启用 C++11 模式。或者您的安装或文件系统已损坏。
标签: c++ macos gcc terminal standard-library