ThreadMentor: Compile and Run Your Programs

Since the CS Department does not use Windows machines for your programming assignments, we only discuss the way of compiling and running your programs on Linux. ThreadMentor uses Linux threads and Pthread on Linux.

Linux (64-bit)

Suppose you have a program with three files quicksort.h (thread definition), quicksort.cpp (thread implementation) and quicksort-main.cpp (the main program). The following makefile compiles this program to an executable file quicksort with the visualization system included:
CC       = c++
FLAGS    = 
CFLAGS   = -g -O2
DFLAGS   = -DPACKAGE=\"threadsystem\" -DVERSION=\"1.0\" -DPTHREAD=1 -DUNIX_MSG_Q=1 -DSTDC_HEADERS=1
IFLAGS   = -I/local/eit-linux/apps/ThreadMentor/include
TMLIB    = /local/eit-linux/apps/ThreadMentor/Visual/libthreadclass.a
TMLIB_NV    = /local/eit-linux/apps/ThreadMentor/NoVisual/libthreadclass.a

OBJ_FILE = quicksort.o quicksort-main.o
EXE_FILE = quicksort 

${EXE_FILE}: ${OBJ_FILE}
        ${CC} ${FLAGS}  -o ${EXE_FILE}  ${OBJ_FILE} ${TMLIB} -lpthread

quicksort.o: quicksort.cpp
        ${CC} ${DFLAGS} ${IFLAGS} ${CFLAGS} -c quicksort.cpp

quicksort-main.o: quicksort-main.cpp
        ${CC} ${DFLAGS} ${IFLAGS} ${CFLAGS} -c quicksort-main.cpp

noVisual: ${OBJ_FILE}
        ${CC} ${FLAGS}  -o ${EXE_FILE}  ${OBJ_FILE} ${TMLIB_NV} -lpthread
                                        
clean:
        rm -f ${OBJ_FILE} ${EXE_FILE}
Click here to download a copy of this file, and here to learn more about makefiles.

By default, the above Makefile compiles a program with visualization activated. Thus, the following compiles the quicksort program with visualization:

make
To compile without visualization, use the following:
make noVisual

Moreover, when you switch from visual to no visual and vice versa, you have to remove the previously generated *.o files. Use the following to remove *.o files:

make clean

To run your program successfully, one line must be added to your .cshrc file, which is in your home directory. You should modify the following if you use a different shell language.

set path=($path /local/eit-linux/apps/ThreadMentor/bin)
This line permits the system to find the visualization system when you need it. After adding this line to your .cshrc, logout and then login again to make them in effect.

Windows

Refer to ThreadMentor FAQ for more details on the Windows build. Please keep in mind that the Windows version is only tested on Windows XP.