Northwest Nexus Frequently Asked Questions
Web Authoring


Compiling C CGI Code For Use On www.halcyon.com:

Q: Why won't my C program run on the web server, it runs fine on the command line?

A: The machine you compiled your program on is different than that of the web server, The code may run directly on the www.halcyon.com server but may have problems because of library incompatibilities.

So how am I supposed to compile my code then?

  1. First try compiling your source on king.halcyon.com. The GCC compiler (gcc) should be used. Then copy your program to your web area and try it out. If it works your all done. If not, try looking at /logs/apache/error_log for errors caused by your program. (The error log is large, you may have to "grep" for your progam or www dir).

    If the above does not work, you may want to try the following.

  2. Make a temporary directory in your web directory, it must be world-writable i.e.
    mkdir compile;chmod 777 compile

  3. Put your code and Makefile there. Create the following shell script in that directory, called makescript, and make it executable, i.e.
    
          ##### Start of "makescript" (do not include) #####
          #!/bin/sh
          #run make as a CGI program
          echo "Content-type: text/plain"
          echo ""
          # if you have no makefile, use whatever commands are necessary to
          # compile program instead of make
          make clean
          make
          ##### End of "makescript" (do not include) #####
          
          chmod 755 makescript
          
          

  4. Now point your browser at http://www.halcyon.com/YOURUSERNAME/compile/makescript, review the output from make to be sure your program compiled correctly. You now have an executable that will run on the webserver. Unfortunately, it'll be owned by nobody and in a world-write directory.

  5. Copy (not move) it to it's final destination (the copy will now be owned by you), i.e.
    cp myc-cgi ../cgi-pvt

  6. Delete the original executable, and remove the temp dir, or at least remove world-write permission.
    rm myc-cgi; chmod 755 compile
Copyright (c) 1998 Northwest Nexus. All Rights Reserved.


Back to FAQ Index Return to FAQ Index Back to Topic Index Return to Topic Index