在我的MacBook中,GNU4.7.1是默认的。当我在学校的服务器上运行我的程序时,我不断地得到大量的分段错误。我从学校服务器下载了程序的当前状态,这样我就可以使用NetBeans来帮助调试。我在让更新的GNU替换我的MacBook继续设置为默认的旧的4.2版本时遇到了很多问题。
OSX编译器对我来说是全新的,我无法调整我的makefile来编译所有的东西,就像它在我学校的服务器上一样。
人们告诉我使用gcc或g++代替其他,但其他人告诉我,这不应该重要。据我所知,OSX为c/c++使用不同的GNU更新版本库,现在Clang是标准吗?我想坚持GNU/GCC,因为这是我在CS课程中使用的。
目前看来,当我的makefile试图链接“std::‘t 19937”时,它找不到链接它的头。
,我的问题是:如何让我的makefile编译,以便使用std::mt19937和c++11库?
makefile
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
# I tried this and adding $(LIBS) where "-std=c++0x" is below..
# LIBS = -std=c++0x -std=c++11 -std=gnu++11
%.o: %.cpp $(HEADERS)
gcc -c $< -o $@ -std=c++0x
Jhack: $(OBJECTS) main.o
gcc -o Jhack $^
clean:
rm -f *.o Jhack
run: Jhack
./Jhack
我试着把"-std=c++0x“换成-std=c++11和-std=gnu++11,我也尝试把它们都加进去。我也试着用g++交换gcc,但是我似乎想要改变的每一件事都会导致更多的错误和警告。
下面是当前错误消息的第一部分(它不停地进行):
gcc -c Ammunition.cpp -o Ammunition.o -std=c++0x
gcc -c Armor.cpp -o Armor.o -std=c++0x
gcc -c Consumable.cpp -o Consumable.o -std=c++0x
gcc -c Creature.cpp -o Creature.o -std=c++0x
gcc -c Entity.cpp -o Entity.o -std=c++0x
gcc -c Gold.cpp -o Gold.o -std=c++0x
gcc -c Item.cpp -o Item.o -std=c++0x
gcc -c parser.cpp -o parser.o -std=c++0x
gcc -c Potion.cpp -o Potion.o -std=c++0x
gcc -c Scroll.cpp -o Scroll.o -std=c++0x
gcc -c Weapon.cpp -o Weapon.o -std=c++0x
gcc -c XMLSerializable.cpp -o XMLSerializable.o -std=c++0x
gcc -c CreatureFactory.cpp -o CreatureFactory.o -std=c++0x
gcc -c DungeonLevel.cpp -o DungeonLevel.o -std=c++0x
gcc -c Player.cpp -o Player.o -std=c++0x
gcc -c Tile.cpp -o Tile.o -std=c++0x
gcc -c ItemFactory.cpp -o ItemFactory.o -std=c++0x
gcc -c main.cpp -o main.o -std=c++0x
gcc -o Jhack 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 main.o
ld: warning: ignoring file Creature.o, file was built for unsupported file format ( 0x7f 0x45 0x4c 0x46 0x 2 0x 1 0x 1 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 ) which is not the architecture being linked (x86_64): Creature.o
Undefined symbols for architecture x86_64:
"Creature::removeMonster(DungeonLevel&)", referenced from:
vtable for Player in Player.o
"Creature::dumpObjectData()", referenced from:
Player::dumpObjectData() in Player.o
"Creature::setElementData(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)", referenced from:
Player::setElementData(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >) in Player.o
"Creature::writeDataAsFragment(std::basic_ostream<char, std::char_traits<char> >&)", referenced from:
Player::writeDataAsFragment(std::basic_ostream<char, std::char_traits<char> >&) in Player.o
"Creature::move(DungeonLevel&, Creature&, std::mersenne_twister_engine<unsigned int, 32ul, 624ul, 397ul, 31ul, 2567483615u, 11ul, 4294967295u, 7ul, 2636928640u, 15ul, 4022730752u, 18ul, 1812433253u>&)", referenced from:
vtable for Player in Player.o
"Creature::getHP()", referenced from:
vtable for Player in Player.o
_main in main.o
"Creature::setHP(int)", referenced from:
Player::Player() in Player.o
Player::Player() in Player.o
vtable for Player in Player.o
"Creature::attack(Creature*, Creature&, std::mersenne_twister_engine<unsigned int, 32ul, 624ul, 397ul, 31ul, 2567483615u, 11ul, 4294967295u, 7ul, 2636928640u, 15ul, 4022730752u, 18ul, 1812433253u>&, DungeonLevel&)", referenced from:
vtable for Player in Player.o
"Creature::getXLoc()", referenced from:
vtable for Player in Player.o
发布于 2013-04-30 13:19:57
结果我搞砸了编译器和MacPorts安装到错误位置的路径?新的OSX安装和适当的GNU未注明日期解决它。
https://stackoverflow.com/questions/16284935
复制