• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

12 replies to this topic

### #1phil67rpg  Members

Posted 20 August 2013 - 09:55 PM

I am working with a shader program for the first time I got it out of the opengl programming guide eight edition "orange book", I am getting the following linker error. I have included the include file folder and the lib file folder into vs 2012. here is the error I am getting:

Error 2 error LNK2019: unresolved external symbol _LoadShaders referenced in function "void __cdecl init(void)" (?init@@YAXXZ) C:\Users\Phillip\Desktop\triangles\triangles\triangles.obj triangles

### #2BitMaster  Members

Posted 21 August 2013 - 02:48 AM

You are calling a function _LoadShaders (minus a bit of name mangling) in your function init(). That function has been declared but never implemented. You are probably not linking a .cpp you would have to link.

### #3MarekKnows.com  Members

Posted 21 August 2013 - 11:06 AM

_LoadShaders ... is that supposed to be a function or a member variable?  How is this defined in your code?

---
Free C++, OpenGL, and Game Development Video Tutorials @
www.MarekKnows.com
Play my free games: Ghost Toast, Zing, Jewel Thief

### #4phil67rpg  Members

Posted 21 August 2013 - 03:40 PM

here  is the code I got out of the book

#include

<iostream>
using

namespace std;
#include

"vgl.h"
#include

enum

VAO_IDs { Triangles, NumVAOs };
enum

Buffer_IDs { ArrayBuffer, NumBuffers };
enum

Attrib_IDs { vPosition=0 };
GLuint

VAOs[NumVAOs];
GLuint

Buffers[NumBuffers];
const

GLuint NumVertices = 6;
void

init(void)
{

glGenVertexArrays(NumVAOs, VAOs);

glBindVertexArray(VAOs[Triangles]);

GLfloat vertices[NumVertices][2] = {
{ -0.90, -0.90 },
{ 0.85, -0.90 },
{ -0.90, 0.85 },
{ 0.90, -0.85 },
{ 0.90, 0.90 },
{ -0.85, 0.90 }
};

glGenBuffers (NumBuffers, Buffers);

glBindBuffer (GL_ARRAY_BUFFER, Buffers[ArrayBuffer]);

glBufferData (GL_ARRAY_BUFFER, sizeof(vertices),vertices,GL_STATIC_DRAW);

{

{

{

GL_NONE, NULL }
};

glUseProgram (program);

glVertexAttribPointer(vPosition,2,GL_FLOAT,GL_FALSE,0,BUFFER_OFFSET(0));

glDisableVertexAttribArray(vPosition);
}
void

display(void)
{
glClear(

GL_COLOR_BUFFER_BIT);

glEnableVertexAttribArray(VAOs[Triangles]);
glDrawArrays(

GL_TRIANGLES,0,NumVertices);
glFlush();
}
int

main(int argc, char** argv)
{

glutInit(&argc,argv);
glutInitDisplayMode(

GLUT_RGBA);
glutInitWindowSize(512,512);
glutInitContextVersion(4,3);
glutInitContextProfile(

GLUT_CORE_PROFILE);

glutCreateWindow(argv[0]);

if (glewInit()) {
cerr <<

"Unable to initialize GLEW ... exiting" << endl;
exit(

EXIT_FAILURE);
}
init();
glutDisplayFunc(display);
glutMainLoop();
}


### #5Bacterius  Members

Posted 21 August 2013 - 03:46 PM

It's not the code. The code is (presumably) fine since you took it out of a book. It's a linker error which means the problem is in how you are compiling the code (you are likely not linking to a library you need, linking to an outdated version of the library, or doing something else wrong). What libraries are you linking against? How are you compiling your code? What is your command-line (or, equivalently, what are your IDE settings?)

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”

### #6phil67rpg  Members

Posted 21 August 2013 - 04:36 PM

well I linked in all the libs I could find and all the include directories. I am using vs2012. I am running out of options. sorry but I am still stuck.

### #7phil67rpg  Members

Posted 21 August 2013 - 08:27 PM

well I have tried everything I can think of but to no avail.

### #8BitMaster  Members

Posted 22 August 2013 - 01:10 AM

well I linked in all the libs I could find

It is highly unlikely that adding random libraries will get you anywhere. The function you are missing is almost certainly written by the author of the program and not available in any external library.

There is a LoadShaders.h included. Most likely there will be a LoadShaders.cpp lying around. That file must be compiled as well and the resulting object files linked. Since you appear to be using MSVC it will probably be enough to add the the file to the project in the solution.

### #9phil67rpg  Members

Posted 22 August 2013 - 01:41 PM

well I added the .cpp files but it still does not work

### #10MarekKnows.com  Members

Posted 22 August 2013 - 01:59 PM

could you post the code found in the .cpp file here

---
Free C++, OpenGL, and Game Development Video Tutorials @
www.MarekKnows.com
Play my free games: Ghost Toast, Zing, Jewel Thief

### #11phil67rpg  Members

Posted 22 August 2013 - 02:23 PM

### #12Cosmic314  Members

Posted 22 August 2013 - 02:31 PM

Did you try moving the include below the extern "C" line like the following:


#ifdef __cplusplus
extern "C" {
#endif // __cplusplus



### #13phil67rpg  Members

Posted 22 August 2013 - 02:37 PM

well I tried the above but it still does not work

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.