title: how to create binary and .so using libtool
body: <p>I have a set of cpp files that I want to compile directly into a binary and also to compile into a shared library.</p>
  
  <p>I have </p>
  
  <pre><code>bin_PROGRAMS=mybin
  lib_LTLIBRARIES=libmylib.la
  
  COMMON_SOURCES=f1.cpp f2.cpp f3.cpp
  
  mybin_SOURCES=main.cpp $(COMMON_SOURCES)
  libmylib_la_SOURCES=$(COMMON_SOURCES)
  </code></pre>
  
  <p>When I run this the cpp files are compiled twice, once with libtool and once without and sometimes libtool/automake complains </p>
  
  <pre><code>Makefile.am: object `f1.$(OBJEXT)' created both with libtool and without`
  </code></pre>
  
  <p>I tried putting COMMON_SOURCES into a .a file but then libtool complains when I link a .a with a .la (saying its not portable).</p>
  
  <p>What I need is something like</p>
  
  <pre><code>bin_LTPROGRAMS=mybin
  </code></pre>
  
  <p>but that doesnt exist</p>
  
  <p>edit: clarification - I am using automake/autoconf. What I have shown above is the meat of my automake Makefile.am</p>