title: Unexpected "Multiple definition" errors in C++ with Qt5
body: <p>I have working code which uses GLFW in C++. Now I want to use it with Qt.
  I'm using a class which inherits QOpenGLWidget. The problem is that in my utils.h and main.cpp files are giving multiple definition errors for all the functions in them while they are defined only once.</p>
  
  <p>make log:</p>
  
  <pre><code>Makefile:597: warning: overriding recipe for target 'main.o'
  Makefile:432: warning: ignoring old recipe for target 'main.o'
  g++ -Wl,-O1 -o Rachaita3DFrontend main.o mainwindow.o oglwidget.o main.o moc_mainwindow.o   -lGLEW -lglfw -lGLX -lSOIL -lstdc++ -lQt5Widgets -lQt5Gui -lQt5Core /usr/lib/x86_64-linux-gnu/libGL.so -lpthread   
  /usr/bin/ld: main.o: in function `ToCompleteEntity(DataStructs::Type*, DataStructs::Position*, DataStructs::Rotation*, DataStructs::Scale*, DataStructs::Mesh*, DataStructs::Shader*)':
  main.cpp:(.text+0x0): multiple definition of `ToCompleteEntity(DataStructs::Type*, DataStructs::Position*, DataStructs::Rotation*, DataStructs::Scale*, DataStructs::Mesh*, DataStructs::Shader*)'; main.o:main.cpp:(.text+0x0): first defined here
  /usr/bin/ld: main.o: in function `LoadTexture(char const*, int, int, MeshInstance)':
  main.cpp:(.text+0x130): multiple definition of `LoadTexture(char const*, int, int, MeshInstance)'; main.o:main.cpp:(.text+0x130): first defined here
  /usr/bin/ld: main.o: in function `key_callback(GLFWwindow*, int, int, int, int)':
  main.cpp:(.text+0x270): multiple definition of `key_callback(GLFWwindow*, int, int, int, int)'; main.o:main.cpp:(.text+0x270): first defined here
  /usr/bin/ld: main.o: in function `Update()':
  main.cpp:(.text+0x290): multiple definition of `Update()'; main.o:main.cpp:(.text+0x290): first defined here
  /usr/bin/ld: main.o: in function `gl()':
  main.cpp:(.text+0x2a0): multiple definition of `gl()'; main.o:main.cpp:(.text+0x2a0): first defined here
  /usr/bin/ld: main.o:(.bss+0x10): multiple definition of `window'; main.o:(.bss+0x10): first defined here
  /usr/bin/ld: main.o:(.bss+0x8): multiple definition of `shader'; main.o:(.bss+0x8): first defined here
  /usr/bin/ld: main.o:(.bss+0x0): multiple definition of `mesh'; main.o:(.bss+0x0): first defined here
  /usr/bin/ld: main.o: in function `resize(int, int)':
  main.cpp:(.text+0x390): multiple definition of `resize(int, int)'; main.o:main.cpp:(.text+0x390): first defined here
  /usr/bin/ld: main.o: in function `LoadToVAO(std::vector&lt;float, std::allocator&lt;float&gt; &gt;, std::vector&lt;unsigned int, std::allocator&lt;unsigned int&gt; &gt;, std::vector&lt;float, std::allocator&lt;float&gt; &gt;, char const*, int, int)':
  main.cpp:(.text+0x3a0): multiple definition of `LoadToVAO(std::vector&lt;float, std::allocator&lt;float&gt; &gt;, std::vector&lt;unsigned int, std::allocator&lt;unsigned int&gt; &gt;, std::vector&lt;float, std::allocator&lt;float&gt; &gt;, char const*, int, int)'; main.o:main.cpp:(.text+0x3a0): first defined here
  /usr/bin/ld: main.o: in function `vecTofloat(std::vector&lt;glm::vec&lt;2, float, (glm::qualifier)0&gt;, std::allocator&lt;glm::vec&lt;2, float, (glm::qualifier)0&gt; &gt; &gt;)':
  main.cpp:(.text+0xba0): multiple definition of `vecTofloat(std::vector&lt;glm::vec&lt;2, float, (glm::qualifier)0&gt;, std::allocator&lt;glm::vec&lt;2, float, (glm::qualifier)0&gt; &gt; &gt;)'; main.o:main.cpp:(.text+0xba0): first defined here
  /usr/bin/ld: main.o: in function `vecTofloat(std::vector&lt;glm::vec&lt;3, float, (glm::qualifier)0&gt;, std::allocator&lt;glm::vec&lt;3, float, (glm::qualifier)0&gt; &gt; &gt;)':
  main.cpp:(.text+0xca0): multiple definition of `vecTofloat(std::vector&lt;glm::vec&lt;3, float, (glm::qualifier)0&gt;, std::allocator&lt;glm::vec&lt;3, float, (glm::qualifier)0&gt; &gt; &gt;)'; main.o:main.cpp:(.text+0xca0): first defined here
  /usr/bin/ld: main.o: in function `loadOBJ(char const*, char const*, int, int)':
  main.cpp:(.text+0xe20): multiple definition of `loadOBJ(char const*, char const*, int, int)'; main.o:main.cpp:(.text+0xe20): first defined here
  /usr/bin/ld: main.o: in function `initGL()':
  main.cpp:(.text+0x1b30): multiple definition of `initGL()'; main.o:main.cpp:(.text+0x1b30): first defined here
  /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
  (.text+0x20): undefined reference to `main'
  /usr/bin/ld: oglwidget.o: in function `OGLWidget::initializeGL()':
  oglwidget.cpp:(.text+0x61): undefined reference to `GL::initGL()'
  /usr/bin/ld: oglwidget.o: in function `OGLWidget::paintGL()':
  oglwidget.cpp:(.text+0x71): undefined reference to `GL::gl()'
  /usr/bin/ld: oglwidget.o: in function `OGLWidget::resizeGL(int, int)':
  oglwidget.cpp:(.text+0x85): undefined reference to `GL::resize(int, int)'
  collect2: error: ld returned 1 exit status
  make: *** [Makefile:167: Rachaita3DFrontend] Error 1
  
  </code></pre>
  
  <p>Here is a simple example for the same.</p>
  
  <p>main1.cpp:</p>
  
  <pre><code>#include "utils1.h"
  #include "main1.h"
  
  void printSomething2{
      printSomething();
  }
  </code></pre>
  
  <p>main1.h:</p>
  
  <pre><code>#ifndef MAIN1_H_INCLUDED
  #define MAIN1_H_INCLUDED
  
  class foo{
      public:
          static void printSomething();
  };
  
  #endif
  </code></pre>
  
  <p>utils1.h:</p>
  
  <pre><code>#ifndef UTILS1_H_INCLUDED
  #define UTILS1_H_INCLUDED
  
  #include &lt;iostream&gt;
  
  void printSomething(){
      std::cout&lt;&lt;"something.";
  }
  
  #endif
  </code></pre>
  
  <p>Example.cpp file calling printSomething()</p>
  
  <pre><code>#include "main1.h"
  
  int main(){
      foo::printSomething();
      return 0;
  }
  </code></pre>
  
  <p>GCC log after compiling Example.cpp:</p>
  
  <pre><code>/usr/bin/ld: /tmp/cc4ft1pF.o: in function `main':
  Ogl1.cpp:(.text+0x5): undefined reference to `foo::printSomething()'
  collect2: error: ld returned 1 exit status
  </code></pre>