views:

93

answers:

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
A: 

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 files g++ is compiling end in .cc so the code in the g++ 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, like stdlib.h should be replaced with includes of the C++ versions, things like cstdlib.

But there will be more too it than that. The code will likely expect things like cerr and cout 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.

Omnifarious
And if it's not printing out the command lines, go find the `@` symbols or `-s` flags and turn them off.
Carl Norum
Why the `.h` was dropped: http://stackoverflow.com/questions/441568/when-can-you-omit-the-file-extension-in-an-include-directive
Omnifarious
A: 

See each of those lines that start:

g++ 

They tell you which executable make is calling!

Johnsyweb