SCUSA Region
ICPC Masthead
2016 ACM ICPC South Central USA Regional Programming Contest
ACM Balloon Logo

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 -static -g -O2 -std=gnu99 -static 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 -static -g -O2 -std=gnu99 -static hello.c -o hello  -lm

Note: Command shown above is actual command used in judging script to compile your code (with hello replaced by the name of your program).

The default gcc version is 5.2.

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++ -static -g -O2 -std=gnu++14 -static hello.cpp -o hello

Note: Command shown above is actual command used in judging script to compile your code (with hello replaced by the name of your program).

The default gpp version is 5.2.

Return to Top of Page





Compile a Java program with Oracle 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

You can type setjava to see what version is the current default. You may type setjava version to change java versions.

Return to Top of Page





Run program with input/output redirection


When the judges execute your program, they do not type input in. The input comes from a file via input redirection. The output of your progrram is redirected to another file. Your output file is then compared to expected out.

Suppose you have the executable hello, and the input file data.in. The actual run command the judging script would use is:

./hello < data.in > data.out

The output in data.out will be compared to the judges expected output to determine correctness. While you are testing your code, it would be wise to edit a text file and type in the sample input from the problem (sample.in). If your source file is doit.c, you would probably use the following work flow:

  • Edit code
  • Compile code (gcc -g -O2 -std=gnu99 -static doit.c -o doit -lm)
  • execute code (./doit < sample.in)