I am not the best yet at OOP practices and that is what is contributing to this bug but I am really needing your help on this. I have a handful of files in here but I will try and post only the relevant pieces.
PLY.cpp:
#include "PLY.hpp"
std::vector<Point> m_VBO;
std::vector<GLuint> m_IBO;
std::shared_ptr<cs5400::Program> program;
GLint attribute_coord3d;
GLuint m_glPoints;
void onDisplay()
{
glClearColor(1.0, 1.0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
glUseProgram(program->getHandle());
glEnableVertexAttribArray(attribute_coord3d);
std::vector<GLfloat> floats;
GLfloat* triangle_verts = floats.data();
glVertexAttribPointer(
attribute_coord3d,
3,
GL_FLOAT,
GL_FALSE,
0,
triangle_verts
);
glDrawArrays(GL_TRIANGLES, 0, 3);
glDisableVertexAttribArray(attribute_coord3d);
glutSwapBuffers();
}
int main(int argc, char* argv[])
{
returnDataFromFile("bun_zipper.ply", m_VBO, m_IBO);
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA|GLUT_DOUBLE|GLUT_DEPTH);
glutInitWindowSize(640, 480);
glutCreateWindow("PLY Importer");
GLenum glew_status = glewInit();
if(glew_status != GLEW_OK)
{
return EXIT_FAILURE;
}
try
{
program = cs5400::make_program //This is the function I'm getting my error on
(
cs5400::make_vertexShader("vertex.glsl"),
cs5400::make_fragmentShader("fragment.glsl")
);
glEnable(GL_DEPTH_TEST);
glutDisplayFunc(onDisplay);
//glutIdleFunc(onIdle);
//glutKeyboardFunc(onKey);
glutMainLoop();
}
catch(std::exception e)
{
std::cerr << e.what();
}
return EXIT_SUCCESS;
};
Ply.h includes the Program.hpp and the Program.cpp looks like:
#include "Program.hpp"
std::shared_ptr<cs5400::Program> cs5400::make_program
(
std::shared_ptr<cs5400::VertexShader> vertex
,std::shared_ptr<cs5400::FragmentShader> fragment
)
{
GLint link_ok = GL_FALSE;
auto program = std::make_shared<Program>(vertex,fragment);
glAttachShader(program->getHandle(), vertex->getHandle());
glAttachShader(program->getHandle(), fragment->getHandle());
glLinkProgram(program->getHandle());
glGetProgramiv(program->getHandle(), GL_LINK_STATUS, &link_ok);
if (!link_ok)
{
throw std::runtime_error("Could not link shader program.");
}
return program;
}
However when compiling I get a LNK2019
error for my std::shared_ptr<cs5400::Program>
piece of my main function in PLY.cpp
. All the includes are correct as far as I know and I don't know what else to do. Anyone have any experience with Linker errors?
Here is the complete error:
1> PLY.obj : error LNK2019: unresolved external symbol "class std::shared_ptr<class cs5400::Program> __cdecl cs5400::make_program(class std::shared_ptr<class cs5400::Shader<struct cs5400::detail::VertexShaderTag> >,class std::shared_ptr<class cs5400::Shader<struct cs5400::detail::FragmentShaderTag> >)" (?make_program@cs5400@@YA?AV?$shared_ptr@VProgram@cs5400@@@std@@V?$shared_ptr@V?$Shader@UVertexShaderTag@detail@cs5400@@@cs5400@@@3@V?$shared_ptr@V?$Shader@UFragmentShaderTag@detail@cs5400@@@cs5400@@@3@@Z) referenced in function _main
1> C:\Users\Brenton\Documents\School\Visual Studio 2012\PLY\Debug\PLY.exe : fatal error LNK1120: 1 unresolved externals