title: linker error: undefined reference c++
body: <p>I've tried looking at similar problems, but could not easily find one that helped my problem.</p>
  
  <p>I've created a project in C++ and am working on UNIX to compile, link, and run it. My specific problem is an undefined reference to a method I declare in a separate file.</p>
  
  <p>In the file SharedCache.cpp, I have the following method:</p>
  
  <pre><code>int SharedCache::replaceLine(ullong address){
      int evictPID = -1;
  
      int cacheSet = calcCacheSet( address );
      //random uniformly-distributed value for cache line
      float numLines = static_cast&lt;float&gt;(CACHE_LINES_PER_SET);
      uint cacheLine = static_cast&lt;uint&gt;(uniformDistr( numLines ));
  
      if(cache[cacheSet][cacheLine] != NULL){
          evictPID = cache[cacheSet][cacheLine]-&gt;PID;
      }
  
      uint PID= calcPID(address);
      uint tag= calcTag(address);
  
      cache[cacheSet][cacheLine]-&gt;setLine(PID, tag); //mutex method
  
      return PID;
  }
  </code></pre>
  
  <p>The line <code>uint cacheLine = static_cast&lt;uint&gt;( uniformDistr( numLines ));</code> makes a call to the function I want to use from another file. The linker error is an undefined reference to this method.</p>
  
  <p>uniformDistr( float ); is declared in the header distributions.h and defined in distributions.cpp. In my project options I set the linker flag -distributions and I also compiled the distributions.cpp to make sure a distributions.o file exists to link with. </p>
  
  <p>From here, I don't know where to go, because this has not solved the problem.</p>