我一直在尝试让我从学校服务器下载的程序在我的 Mac 上离线运行。我尝试按照教程更新 GCC,但由于某种原因,即使我使用了给定的命令,教程也不起作用。
现在,当我编译时..我收到一条错误,指出未找到..我不明白。我已经更新了 Xcode..遵循了大量的教程..但我仍然无法运行它!
为什么会说找不到随机数,导致致命错误?
Thanks
Error:
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
苹果的gcc确实已经过时了。尝试使用 clang 和 libc++ 而不是 gcc 和 libstdc++ 进行构建。编译标志:-std=c++11 -stdlib=libc++
,链接标志:-stdlib=libc++
。使用 clang++ 而不是 g++。
Edit:请注意,您需要安装最新的命令行工具才能正常工作。
打开 XCode。转到“Xcode”->“首选项...”->“下载”选项卡。选择“命令行工具”并安装它们。如果显示已安装 - 单击“立即检查并安装”按钮检查更新。
在该类型之后clang++ --version
在终端中,您应该看到类似以下内容:
Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin12.3.0
Thread model: posix
Edit 2:如果这没有帮助,并且您仍然拥有过时的编译器版本。尝试使用xcrun clang++
代替clang++
在你的 makefile 中。这将使用 xcode 工具链。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)