title: g++ undefined reference to `main'
body: <p>I have a gcc 5.2.0 configured as follows :</p>
  
  <pre><code>Using built-in specs.
  COLLECT_GCC=gcc-5.2.0
  COLLECT_LTO_WRAPPER=/usr/local/lvm/gcc-5.2.0/libexec/gcc/x86_64-unknown-linux-gnu/5.2.0/lto-wrapper
  Target: x86_64-unknown-linux-gnu
  Configured with: ../configure --prefix=/usr/local/lvm/gcc-5.2.0 --enable-checking=release --with-gmp=/usr/local/lvm/gmp-6.0.0 --with-mpfr=/usr/local/lvm/mpfr-3.1.2 --with-mpc=/usr/local/lvm/mpc-1.0.3 --enable-languages=c,c++,fortran,objc,obj-c++ --with-isl=/usr/local/lvm/isl-0.14 --with-cloog=/usr/local/lvm/cloog-0.18.4 --program-suffix=-5.2.0
  Thread model: posix
  gcc version 5.2.0 (GCC)
  </code></pre>
  
  <p>and g++ :</p>
  
  <pre><code>Using built-in specs.
  COLLECT_GCC=g++-5.2.0
  COLLECT_LTO_WRAPPER=/usr/local/lvm/gcc-5.2.0/libexec/gcc/x86_64-unknown-linux-gnu/5.2.0/lto-wrapper
  Target: x86_64-unknown-linux-gnu
  Configured with: ../configure --prefix=/usr/local/lvm/gcc-5.2.0 --enable-checking=release --with-gmp=/usr/local/lvm/gmp-6.0.0 --with-mpfr=/usr/local/lvm/mpfr-3.1.2 --with-mpc=/usr/local/lvm/mpc-1.0.3 --enable-languages=c,c++,fortran,objc,obj-c++ --with-isl=/usr/local/lvm/isl-0.14 --with-cloog=/usr/local/lvm/cloog-0.18.4 --program-suffix=-5.2.0
  Thread model: posix
  gcc version 5.2.0 (GCC)
  </code></pre>
  
  <p>I have the following simple c++ code in tmp2.cpp file :</p>
  
  <pre><code>extern "C" {
        double mysum(double x, double y)
        {
              return x+y;
        }
  }
  </code></pre>
  
  <p>that I am trying to compile into a dynamic library (.so) as follows :</p>
  
  <pre><code>export LD_LIBRARY_PATH=/usr/local/lvm/gmp-6.0.0:/usr/local/lvm/mpfr-3.1.2:/usr/local/lvm/mpc-1.0.3:/usr/local/lvm/cloog-0.18.4:/usr/local/lvm/isl-0.14/lib:/usr/local/lvm/gcc-5.2.0/lib64
  export PATH=/usr/local/lvm/gcc-5.2.0/bin/:$PATH
  g++-5.2.0 -m32 -Wall -g -c ./tmp2.cpp
  g++-5.2.0 -m32 -dynamiclib ./tmp2.o -o ./tmp2.so
  </code></pre>
  
  <p>and the last command gives me the following error :</p>
  
  <pre><code>/usr/lib/../lib32/crt1.o: In function `_start':
  (.text+0x18): undefined reference to `main'
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>The detail output thx to <code>-v</code> can be found in a gist <a href="https://gist.github.com/MisesEnForce/097c8a9e37ebdc61a041" rel="nofollow">here</a>.</p>
  
  <p>I am quite new to gcc/g++ and don't really get what is going on. What's happened ?</p>