Compile Howto
This page will list a number of useful processes that may be helpful to contest competitors.
How to run an executable in the current directory
For security reasons, the current directory is NOT in your path. This means that if
you wish to run the executable
hello that is in the same directory that you
are in, you must type:
./hello. This says to explicitly run the
hello
executable that is in the current directory.
Return to Top of Page
Compile a C program with gcc
The
gcc command is used to invoke the GNU C compiler. Both input
source file and executable file name must be specified. This is the command
to use if you have a C source file called
hello.c and wish to
create the executable file
hello.
gcc hello.c -o hello
If you are including
<math.h> do not forget to put the
-lm
at the end of the compile line.
gcc hello.c -o hello -lm
Return to Top of Page
Compile a C++ program with g++
The
g++ command is used to invoke the GNU C++ compiler. Both input
source file and executable file name must be specified. This is the command
to use if you have a C++ source file called
hello.cpp and wish to
create the executable file
hello.
g++ hello.cpp -o hello
Return to Top of Page
Compile a Java program with Sun JDK
The
javac command is used to compile java source files.
javac hello.java
This will produce
java.class.
Return to Top of Page
Execute a compiled Java program
The
java command is used to execute java class file.
java hello
Return to Top of Page