What I'd like to do is use glUseProgram(); which is an OpenGL function however too use it returns problems....
Why?
Because apparently even when declaring a seperate header file with an declared extern variable then using it in my main.cpp file and user-defined OpenGL Engine structure definition gives me errors with MSVC 2013
Here is a test case using only generic c++:
variable_header.hpp
extern int ProgramID = whateverfunctionyouwant(); OGL_Engine.hpp
#ifndef __OGL_ENGINE_HPP__ #define __OGL_ENGINE_HPP__ struct OGL_Engine { int Setup(); int ShaderSetup(); }; #endif OGL_Engine.cpp
#ifndef __OGL_ENGINE_CPP__ #define __OGL_Engine_CPP__ int OGL_Engine::Setup(){ int whatever = 0; } int OGL_Engine::ShaderSetup(){ int readfile = 0; afunctionyouwant(ProgramID); } #endif The errors I get are :
Error 3 error LNK1169: one or more multiply defined symbols found
This happens in my original files, not test case but it should say this I hope.
externvariables are declared in headers and defined in source files. Try moving the definition and initialization to a source file.variable_header.hpp. Do you have them in the original? Please include a minimal, complete, verifiable example along with the exact error message(s) you get when you try to build the MCVE.