ICPC Masthead
    • Regional
      • Results
      • Welcome
      • Quick Facts
      • Rules
      • Hints
      • Compile Howto
      • FAQ
      • Contact
    • Results
    • Sites
      • Baylor
      • LSU
      • SELU
      • SNU/OU
      • UTSA
    • ACM
      • International Collegiate Programming Contest
      • South Central US Regional
      • Registration
      • ICPC Regional Rules
    • Localdoc
    • History
      • ACM 2017
      • ACM 2016
      • ACM 2015
      • ACM 2014
      • ACM 2013
      • ACM 2012
      • ACM 2011
      • ACM 2010
      • ACM 2009
      • ACM 2008
      • ACM 2007
      • ACM 2006
      • ACM 2005
      • ACM 2004
      • ACM 2003
      • ACM 2002
      • ACM 2001
      • ACM 2000

    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
    • Compile a C program with gcc
    • Compile a C++ program with g++
    • Compile a Java program with Oracle JDK
    • Execute a compiled Java program
    • Run program with input/output redirection



    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).


    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).


    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)
Please direct any questons to: management@scusa.lsu.edu.
The statements and opinions included in these pages are those of the Hosts of the ACM ICPC South Central USA Regional Programming Contest only.
© 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 ACM ICPC South Central USA Regional Programming Contest.