title: "undefined reference to" during passing file to function
body: <p>program output: c:/program files/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\michal\AppData\Local\Temp\cczDvNoc.o:main.cpp:(.text+0x25): undefined reference to `openFile(std::basic_ifstream >&amp;)'
  collect2.exe: error: ld returned 1 exit status</p>
  
  <p>main.cpp:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  #include "libs/libFiles.hpp"
  
  int main()
  {  
      std::ifstream myFile;
      openFile(myFile);
  
  }
  
  </code></pre>
  
  <p>libFiles.cpp:</p>
  
  <pre><code>#include &lt;fstream&gt;
  #include &lt;string&gt;
  #include "libFiles.hpp"
  
  void openFile(std::ifstream &amp;myFile)
  {
  
      std::string fileName;
      std::cout &lt;&lt; "Enter name of the file to open: " &lt;&lt; std::endl;
      std::cin &gt;&gt; fileName;
      do
      {
          myFile.open(fileName, std::ios::in);
          if (myFile.good() == true)
              std::cout &lt;&lt; "Access granted\n";
          else
          {
              if (fileName.substr(fileName.find_last_of(".") + 1) == "txt")
              {
                  std::cout &lt;&lt; "Access denied\n";
                  exit(0);
              }
              else
                  fileName += ".txt";
          }
      } while (myFile.good() == false);
  }
  </code></pre>
  
  <p>libFiles.hpp</p>
  
  <pre><code>#ifndef libFiles_hpp
  #define libFiles_hpp
  #include &lt;iostream&gt;
  #include &lt;fstream&gt;
  
  void openFile(std::ifstream &amp;);
  void readFile(std::ifstream &amp;);
  
  #endif
  </code></pre>