I am attempting to use Nanovg in my OpenGL project and am getting repeated multiple definition errors such as
CMakeFiles\http://ift.tt/1oov50l: multiple definition of `nvgCreateGL3'
CMakeFiles\http://ift.tt/1q5SdT2: first defined here
Game.h
  class Game {
    public:
      void Run();
      Game(std::string Title, ScreenMode ScreenMode, int Width, int MSAASamples, bool VSync);
    private:
      GLFWwindow* Window;
      NVGcontext* VGContext;
      std::string Title;
      ScreenMode Mode;
      int Width, Height;
      int WWidth, WHeight;
      int FBWidth, FBHeight;
      int MSAASamples;
      bool VSync;
      bool Exit;
      float PixRatio;
      void Process();
      void Render();
      void KeyCallback(GLFWwindow* Window, int Key, int Scancode, int Action, int Mode);
      void SaveScreenShot(const std::string* Path);
  };
Game.cpp
//various #includes .. (STL GlaD, GLFW)
#ifndef NANOVG_INCLUDED
#define NANOVG_INCLUDED
#include <nanovg.h>
#define NANOVG_GL3_IMPLEMENTATION
#include <nanovg_gl.h>
#endif
// More #includes ...
#include <Game.h>
Game::Game(std::string Title, ScreenMode ScreenMode, int Width, int MSAASamples, bool VSync)
{
  // constructor here
}
void Game::Run(){
  // Initialise openGl and NanoVG, then into main game loop calling `Render();`
}
Render.cpp
//various #includes .. (STL GlaD, GLFW)
#ifndef NANOVG_INCLUDED
#define NANOVG_INCLUDED
#include <nanovg.h>
#define NANOVG_GL3_IMPLEMENTATION
#include <nanovg_gl.h>
#endif
// More #includes ...
#include <Game.h>
void Game::Render() {
  //Definition using Nanovg
}
Here are some other things that may be useful CMakeLists Available Here
Full Console output Available Here
What I have tried
- Putting the line 
#define NANOVG_GL3_IMPLEMENTATIONin Game.h - Putting the Nanovg includes AND the 
#define ...in Game.h - tried changing the location WHERE Game.h and the nanovg libs are placed with 
#includes ...(causes unknown type errors) 
Many thanks in advance for the help with this issue
Aucun commentaire:
Enregistrer un commentaire