title: Undefined reference to 'main' when using ifort/icc
body: <p>I am trying to compile a code that is written in Fortran and then linked through the C compiler. The problem comes when I try the Intel compilers, ifort + icc. If I do the same with GNU compilers, gfortran + gcc, it works.</p>
  
  <p>Bellow we can see their outputs.</p>
  
  <p><strong>ICC, <em>not</em> working:</strong></p>
  
  <blockquote>
    <p>ifort -c  -o fonts/pgpack.o -g -fno-automatic -fPIC fonts/pgpack.f
    ifort: command line warning #10006: ignoring unknown option '-fno-automatic'<br>
    icc -o pgpack  fonts/pgpack.o   -O2  -L/opt/intel/composer_xe_2013_sp1.0.080/compiler/lib/intel64 -L/opt/intel/composer_xe_2013_sp1.0.080/ipp/../compiler/lib/intel64 -L/opt/intel/composer_xe_2013_sp1.0.080/ipp/lib/intel64 -L/opt/intel/composer_xe_2013_sp1.0.080/compiler/lib/intel64 -L/opt/intel/composer_xe_2013_sp1.0.080/mkl/lib/intel64 -L/opt/intel/composer_xe_2013_sp1.0.080/tbb/lib/intel64/gcc4.4 -L/opt/intel/composer_xe_2013_sp1.0.080/compiler/lib/intel64 -L/usr/lib/gcc/x86_64-redhat-linux/4.4.7/ -L/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/ -L/lib/../lib64 -L/lib/../lib64/ -L/usr/lib/../lib64 -L/usr/lib/../lib64/ -L/opt/intel/composer_xe_2013_sp1.0.080/compiler/lib/intel64/ -L/opt/intel/composer_xe_2013_sp1.0.080/ipp/../compiler/lib/intel64/ -L/opt/intel/composer_xe_2013_sp1.0.080/ipp/lib/intel64/ -L/opt/intel/composer_xe_2013_sp1.0.080/mkl/lib/intel64/ -L/opt/intel/composer_xe_2013_sp1.0.080/tbb/lib/intel64/gcc4.4/ -L/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../ -L/lib64 -L/lib/ -L/usr/lib64 -L/usr/lib -L/opt/intel/composer_xe_2013_sp1.0.080/compiler/lib/intel64 -L/opt/intel/composer_xe_2013_sp1.0.080/ipp/../compiler/lib/intel64 -L/opt/intel/composer_xe_2013_sp1.0.080/ipp/lib/intel64 -L/opt/intel/composer_xe_2013_sp1.0.080/compiler/lib/intel64 -L/opt/intel/composer_xe_2013_sp1.0.080/mkl/lib/intel64 -L/opt/intel/composer_xe_2013_sp1.0.080/tbb/lib/intel64/gcc4.4 -L/opt/intel/composer_xe_2013_sp1.0.080/compiler/lib/intel64 -L/usr/lib/gcc/x86_64-redhat-linux/4.4.7/ -L/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/ -L/lib/../lib64 -L/lib/../lib64/ -L/usr/lib/../lib64 -L/usr/lib/../lib64/ -L/opt/intel/composer_xe_2013_sp1.0.080/compiler/lib/intel64/ -L/opt/intel/composer_xe_2013_sp1.0.080/ipp/../compiler/lib/intel64/ -L/opt/intel/composer_xe_2013_sp1.0.080/ipp/lib/intel64/ -L/opt/intel/composer_xe_2013_sp1.0.080/mkl/lib/intel64/ -L/opt/intel/composer_xe_2013_sp1.0.080/tbb/lib/intel64/gcc4.4/ -L/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../ -L/lib64 -L/lib/ -L/usr/lib64 -L/usr/lib -lifport -lifcore -limf -lsvml -lm -lipgo -lirc -lpthread -lsvml -lc -lgcc -lgcc_s -lirc_s -ldl -lc<br>
    /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o: In function '_start':<br>
    (.text+0x20): undefined reference to `main'</p>
  </blockquote>
  
  <p><em>Note</em>: it is strange to me that icc is linking against gcc libraries (/usr/lib/gcc/...). Is this normal/right?</p>
  
  <p><strong>GCC, working:</strong></p>
  
  <blockquote>
    <p>gfortran -c  -o fonts/pgpack.o -O2 -Wall -fno-second-underscore -g  -fno-automatic -fPIC fonts/pgpack.f<br>
    Warning: Nonconforming tab character in column 6 of line 15<br>
    Warning: Nonconforming tab character in column 6 of line 16<br>
    Warning: Nonconforming tab character in column 6 of line 17<br>
    Warning: Nonconforming tab character in column 2 of line 19<br>
    Warning: Nonconforming tab character in column 2 of line 20<br>
    Warning: Nonconforming tab character in column 2 of line 21<br>
    Warning: Nonconforming tab character in column 2 of line 24<br>
    Warning: Nonconforming tab character in column 2 of line 25<br>
    gcc -o pgpack  fonts/pgpack.o   -O2  -L/usr/lib/gcc/x86_64-redhat-linux/4.4.7 -L/usr/lib/gcc/x86_64-redhat-linux/4.4.7 -L/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/opt/intel/composer_xe_2013_sp1.0.080/compiler/lib/intel64 -L/opt/intel/composer_xe_2013_sp1.0.080/ipp/../compiler/lib/intel64 -L/opt/intel/composer_xe_2013_sp1.0.080/ipp/lib/intel64 -L/opt/intel/composer_xe_2013_sp1.0.080/compiler/lib/intel64 -L/opt/intel/composer_xe_2013_sp1.0.080/mkl/lib/intel64 -L/opt/intel/composer_xe_2013_sp1.0.080/tbb/lib/intel64/gcc4.4 -L/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../.. -L/usr/lib/gcc/x86_64-redhat-linux/4.4.7 -L/usr/lib/gcc/x86_64-redhat-linux/4.4.7 -L/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/opt/intel/composer_xe_2013_sp1.0.080/compiler/lib/intel64 -L/opt/intel/composer_xe_2013_sp1.0.080/ipp/../compiler/lib/intel64 -L/opt/intel/composer_xe_2013_sp1.0.080/ipp/lib/intel64 -L/opt/intel/composer_xe_2013_sp1.0.080/compiler/lib/intel64 -L/opt/intel/composer_xe_2013_sp1.0.080/mkl/lib/intel64 -L/opt/intel/composer_xe_2013_sp1.0.080/tbb/lib/intel64/gcc4.4 -L/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../.. -lgfortranbegin -lgfortran -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc<br>
    : pgpack  </p>
  </blockquote>
  
  <p>I notice that some libraries being linked changed (e.g, libgfortranbegin), but that is automatically added/changed by the make system.</p>
  
  <p>I already tried solutions offered by other posts, for similar errors, like use the flag (ifort)<code>-nofor-main</code> and (icc)<code>-nostartfiles</code>, but it keeps failing.</p>
  
  <p>What am I missing?
  Thanks.</p>