如何知道 make 正在使用 gcc 还是 g++
如果我运行 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
If I run make then how can I tell if gcc or g++ is being used? I tried to look at the Makefile but didn't find anything.
Here is the output from make. I can't figure it out from this either.
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Make 应该吐出它正在运行的命令行。这些应该告诉您它正在调用哪个编译器。
既然您发布了它们,现在很清楚 make 正在调用
g++
。此外,文件g++
正在编译.cc
中,因此g++
前端中的代码会调用的 C 编译器.c
文件将不会被激活。我敢打赌,您感到困惑的是找不到
iostream.h
。由于各种奇怪的原因,标准委员会决定删除标准头文件名称中的.h
。大多数编译器在之后的相当长一段时间内仍然支持使用.h
以避免破坏旧代码。但在过去几年中,这一点已被放弃,部分原因是几乎所有包含.h
版本头文件的程序也不期望符号位于::std< /代码> 命名空间。
另外,大多数人已经停止使用 C++ 的
.cc
扩展(我对此感到非常难过,但我喜欢它)。结合这些事情告诉我,您正在尝试编译为旧的、准标准 C++ 编译器编写的代码,并且从未更新过。如果您希望代码能够编译,您需要做一些小的移植工作。移植工作的第一步是将
#include
替换为#include
。还包括标准 C 库头文件,例如stdlib.h
,应替换为 C++ 版本的包含文件,例如cstdlib
。但还会有更多的事情。代码可能期望
cerr
和cout
之类的东西位于根级命名空间中,而后标准 C++ 将它们放在::std
中> 命名空间。您必须修复代码才能使用该名称空间。幸运的是,所有这些事情都可能会因缺少包含文件或无法找到的符号而产生编译器错误,因此这不会太难。
我刚刚查找了您似乎正在尝试编译的 nachos 库,而且它确实很老了,已经很长时间没有更新了。他们提到的编译器是 gcc 2.6,这是一个绝对古老的编译器。
Make should be spitting out the command lines it's running. Those should tell you what compiler it's calling.
And since you posted them, it's now clear that make is calling
g++
. Additionally, the filesg++
is compiling end in.cc
so the code in theg++
front-end which invokes the C compiler for.c
files will not be activated.I bet that what you are confused about is the fact
iostream.h
can't be found. For various strange reasons the standards committee decided to drop the.h
in the names of the standard header files. Most compilers still supported using the.h
for quite some time afterwards in order to avoid breaking old code. But this has been dropped in the past few years, partly because almost all programs that include the.h
version of the header file also do not expect the symbols to be in the::std
namespace.Also, most people have stopped using the
.cc
extension for C++ (I'm rather sad about this, I liked it). Combined these things tell me you're trying to compile code that's written for old, pre-standards C++ compilers and has never been updated. You have a small porting effort ahead of you if you want the code to compile.The first step in your porting effort is to replace
#include <iostream.h>
with#include <iostream>
. Also includes of standard C library headers, likestdlib.h
should be replaced with includes of the C++ versions, things likecstdlib
.But there will be more too it than that. The code will likely expect things like
cerr
andcout
to be in the root level namespace, and post-standards C++ has them in the::std
namespace. You're going to have to fix the code to use that namespace.Luckily all of these things will probably generate compiler errors for missing include files or symbols it can't find, so this won't be too hard.
I just looked up the nachos library you seem to be trying to compile, and it is indeed very old and hasn't been updated in a very long time. The compiler they mention is gcc 2.6, which is an absolutely ancient compiler.