JGe*_*eis 3 c++ macos terminal gcc standard-library
我一直试图让我从学校服务器下载的程序在我的mac上脱机运行.我尝试通过以下教程更新GCC,由于某些原因,即使我使用给定的命令,教程也不起作用.
现在当我编译..我得到一个错误,说没有找到..我不明白.我已经更新了Xcode ..跟随了大量的教程..我仍然无法得到运行的东西!
为什么说找不到随机,导致致命错误?
谢谢
DungeonLevel.h:6:10: fatal error: 'random' file not found
Run Code Online (Sandbox Code Playgroud)
#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
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
Apple的gcc真的已经过时了.尝试使用clang和libc ++而不是gcc和libstdc ++构建.编译标志:-std=c++11 -stdlib=libc++,链接标志:-stdlib=libc++.使用clang ++而不是g ++.
编辑:请注意,您需要安装最新的命令行工具才能使其正常工作.
打开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
Run Code Online (Sandbox Code Playgroud)
编辑2:如果这没有帮助,你仍然有一个过时的编译器版本.尝试使用xcrun clang++而不是clang++在您的makefile中.那将使用xcode工具链.