title: Strange scenario getting g++ error multiple definition of functions
body: <p>I have code that already works but need to port it to yet another Linux platform.  I'm always having to tune the code for gcc/g++ differences - usually the given version of g++ is just more limited in what it allows.</p>
  
  <p>In this case, I am getting a multiple function definition error in a very simple case - a single global function in a single cpp file being called once. I do not see any duplicate listing of the object file in the final g++ link line. There are no duplicates either in the source file text (by searching), or in the compiled object file (using objdump -t).  In fact, the error confirms there is no true duplicate by listing the same offset in the object:</p>
  
  <p>ACTUAL LINK ERROR:
  Simulation1.o: In function <code>DoSimulation1(int, char**)':
  Simulation1.cpp:(.text+0x1800): multiple definition of</code>DoSimulation1(int, char**)'
  Simulation1.o:Simulation1.cpp:(.text+0x1800): first defined here</p>
  
  <p>Note two odd things - (1) both original and duplicate are at .text+0x1800, and (2) it seems to be finding a duplicate of the function being called inside the function, but this is not a recursive function and it does not call itself.</p>
  
  <p>Here's the link line:</p>
  
  <blockquote>
    <p>g++ -O3 -std=c++11 CorrelatePCandFrequency.o CountBroadcasts.o
    CheckMemDependencies.o MathModel.o Histograms2.o EvalOddSetCaches2.o
    jDEQ.o ChipControl.o jSimplestCache.o WorkingSets.o
    EvalOddSetCaches3.o QuickAnal.o Simulation1.o copy.o
    ValidateTrailFile.o jCommon.o CountBroadcasts2.o jSimpleCache2.o
    BankConflicts.o ParsePTXTrace.o DynamicTrace.o copy.o Simulation1.o
    Histograms.o jExcel.o main.o jPreConditionedHintFile.o JVector.o
    jBitArray.o Ops.o -o sim</p>
  </blockquote>
  
  <p>The single function definition in the file Simulation1.cpp:</p>
  
  <pre><code>bool DoSimulation1(int argc, char* argv[])
    {
    ...
    }
  </code></pre>
  
  <p>Note that when I do objdump -t on Simulation1.o and then c++filt, I get a slight variation:</p>
  
  <p>0000000000001800 g     F .text  000000000000049b _Z13DoSimulation1iPPc</p>
  
  <p>c++filt _Z13DoSimulation1iPPc
  DoSimulation1(int, char**)</p>
  
  <p>So if there's anything a miss it could be the difference between char** and char* [])</p>
  
  <p>Again, this compiles fine on other platforms.
  This error is with:
  gcc version 4.7.2 20121109 (Red Hat 4.7.2-8) (GCC) </p>
  
  <p>Any thoughts?  Normally errors like this are from putting a definition in an include file, or having weird template overloading effects.  This is quite simple, and it won't link the executable as a result.</p>
  
  <p>Thanks
  - Jeff</p>