如果我运行make,那么如何判断是否正在使用gcc或g ++?我试着看看Makefile但没找到任何东西。
这是make的输出。我无法弄清楚这一点。
cd threads; make depend
make[1]: Entering directory `/home/anthony/nachos-4.0/code/threads'
g++ -I../lib -I../threads -I../machine -DTHREADS -Dx86 -DLINUX -DCHANGED -M ../lib/bitmap.cc ../lib/debug.cc ../lib/hash.cc ../lib/libtest.cc ../lib/list.cc ../lib/sysdep.cc ../machine/interrupt.cc ../machine/stats.cc ../machine/timer.cc ../threads/alarm.cc ../threads/kernel.cc ../threads/main.cc ../threads/scheduler.cc ../threads/synch.cc ../threads/synchlist.cc ../threads/thread.cc ../machine/elevatortest.cc ../machine/elevator.cc > makedep
In file included from ../lib/debug.h:18,
from ../lib/bitmap.cc:10:
../lib/sysdep.h:15:22: error: iostream.h: No such file or directory
In file included from ../lib/debug.h:18,
from ../lib/debug.cc:11:
../lib/sysdep.h:15:22: error: iostream.h: No such file or directory
In file included from ../lib/debug.h:18,
from ../lib/list.h:17,
from ../lib/libtest.cc:12:
../lib/sysdep.h:15:22: error: iostream.h: No such file or directory
In file included from ../lib/debug.h:18,
from ../lib/sysdep.cc:27:
../lib/sysdep.h:15:22: error: iostream.h: No such file or directory
In file included from ../lib/debug.h:18,
from ../lib/list.h:17,
from ../machine/interrupt.h:39,
from ../machine/interrupt.cc:24:
../lib/sysdep.h:15:22: error: iostream.h: No such file or directory
In file included from ../lib/debug.h:18,
from ../machine/stats.cc:11:
../lib/sysdep.h:15:22: error: iostream.h: No such file or directory
In file included from ../lib/debug.h:18,
from ../threads/main.h:13,
from ../machine/timer.cc:24:
../lib/sysdep.h:15:22: error: iostream.h: No such file or directory
In file included from ../lib/debug.h:18,
from ../threads/main.h:13,
from ../threads/alarm.cc:13:
../lib/sysdep.h:15:22: error: iostream.h: No such file or directory
In file included from ../lib/debug.h:18,
from ../threads/kernel.cc:9:
../lib/sysdep.h:15:22: error: iostream.h: No such file or directory
In file included from ../lib/debug.h:18,
from ../threads/main.h:13,
from ../threads/main.cc:21:
../lib/sysdep.h:15:22: error: iostream.h: No such file or directory
In file included from ../lib/debug.h:18,
from ../threads/scheduler.cc:22:
../lib/sysdep.h:15:22: error: iostream.h: No such file or directory
In file included from ../threads/thread.h:42,
from ../threads/synch.h:21,
from ../threads/synch.cc:36:
../lib/sysdep.h:15:22: error: iostream.h: No such file or directory
In file included from ../lib/debug.h:18,
from ../lib/list.h:17,
from ../threads/synchlist.h:14,
from ../threads/synchlist.cc:13:
../lib/sysdep.h:15:22: error: iostream.h: No such file or directory
In file included from ../threads/thread.h:42,
from ../threads/thread.cc:20:
../lib/sysdep.h:15:22: error: iostream.h: No such file or directory
In file included from ../lib/debug.h:18,
from ../lib/list.h:17,
from ../machine/elevator.h:24,
from ../machine/elevatortest.cc:13:
../lib/sysdep.h:15:22: error: iostream.h: No such file or directory
In file included from ../lib/debug.h:18,
from ../lib/list.h:17,
from ../machine/elevator.h:24,
from ../machine/elevator.cc:11:
../lib/sysdep.h:15:22: error: iostream.h: No such file or directory
make[1]: *** [depend] Error 1
make[1]: Leaving directory `/home/anthony/nachos-4.0/code/threads'
make: *** [all] Error 2
答案 0 :(得分:1)
Make应该吐出它正在运行的命令行。那些应该告诉你它正在调用什么编译器。
自从你发布了它们之后,现在很清楚make正在调用g++
。此外,文件g++
正在.cc
中编译结束,因此g++
前端中调用.c
文件的C编译器的代码将不会被激活。
我敢打赌,你感到困惑的是iostream.h
无法找到的事实。由于各种奇怪的原因,标准委员会决定将.h
放在标准头文件的名称中。大多数编译器仍然支持使用.h
一段时间后,以避免破坏旧代码。但是这在过去几年中已被删除,部分原因是几乎所有包含头文件.h
版本的程序也不希望这些符号位于::std
命名空间中。
此外,大多数人已经停止使用C ++的.cc
扩展名(我对此感到非常难过,我喜欢它)。结合这些东西告诉我你正在尝试编译为旧的预标准C ++编译器编写的代码,并且从未更新过。如果您希望编译代码,那么您需要进行一些小的移植工作。
移植工作的第一步是将#include <iostream.h>
替换为#include <iostream>
。还包括标准C库头文件,例如stdlib.h
应替换为包含C ++版本的内容,例如cstdlib
。
但也会有更多。代码可能会期望cerr
和cout
之类的内容位于根级别命名空间中,而后标准C ++则将它们放在::std
命名空间中。您将不得不修复代码以使用该命名空间。
幸运的是,所有这些事情都可能会因缺少包含文件或无法找到的符号而产生编译器错误,所以这不会太难。
我只是查看了你似乎想要编译的nachos library,它确实很老,并且在很长一段时间内都没有更新。他们提到的编译器是gcc 2.6,这是一个绝对古老的编译器。