Go up to the main documents page (md)
This page is intended to help when your code does not compile.
There are a number of things you can try:
#include
are not present, then it won’t
compile.#include "FileName.h"
and your file is named filename.h,
this will NOT compile under Linux. Change your file name cases, or your
#include
line.#include
lines?
If it is complaining that it can’t find exit()
, for
example, be sure to #include <stdlib.h>
. Many
compilers automatically include <stdlib.h>
and
<stdio.h>
, which means you can directly call
functions such as printf()
and exit()
without
the appropriate #include
line. The compiler used by the
submission system does not include, by default, any
#include
files.using namespace std;
at the top of each
file?make
(you learn about make
and Makefiles about 1/3 of the way through the course), then your
Makefile needs to be configured to properly compile the code-o
compiler option. This means it will produce a.out (on Linux and Mac OS
X). The system checks to see that the binary file was produced before it
claims compilation success (and since the system is running on a Linux
machine, it looks for a.out).Here are a few additional things to try:
In the fall of 2013, we switched over to clang from g++. Thus, the error messages that we had in this section are going to be different with clang. If you run into something that you don’t understand, please let us know!