Sign in to follow this  
phil67rpg

error message

Recommended Posts

weil I am getting the following error.
[font="Consolas"][size="1"][font="Consolas"][size="1"]ImageLoad.obj : error LNK2019: unresolved external symbol _gltLoadTGA referenced in function _RenderScene

1>C:\Users\phil\documents\visual studio 2010\Projects\image\Debug\image.exe : fatal error LNK1120: 1 unresolved externals

here is the code I am working on.I am using opengl and c. I think I am missing a library but am unsure of which one.
[source lang = "c"]
[font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]

#include[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] [/size][/font][/size][/font][font="Consolas"][size="2"][color="#a31515"][font="Consolas"][size="2"][color="#a31515"][font="Consolas"][size="2"][color="#a31515"]<stdlib.h>

[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]#include[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] [/size][/font][/size][/font][font="Consolas"][size="2"][color="#a31515"][font="Consolas"][size="2"][color="#a31515"][font="Consolas"][size="2"][color="#a31515"]<math.h>

[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]#include[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] [/size][/font][/size][/font][font="Consolas"][size="2"][color="#a31515"][font="Consolas"][size="2"][color="#a31515"][font="Consolas"][size="2"][color="#a31515"]<glut.h>

[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]#include[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] [/size][/font][/size][/font][font="Consolas"][size="2"][color="#a31515"][font="Consolas"][size="2"][color="#a31515"][font="Consolas"][size="2"][color="#a31515"]"Common/OpenGLSB.h"[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] [/size][/font][/size][/font][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"]// System and OpenGL Stuff

[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]#include[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] [/size][/font][/size][/font][font="Consolas"][size="2"][color="#a31515"][font="Consolas"][size="2"][color="#a31515"][font="Consolas"][size="2"][color="#a31515"]"Common/GLTools.h"[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] [/size][/font][/size][/font][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"]// OpenGL toolkit

[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]

[/size][/font][/size][/font][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"]//////////////////////////////////////////////////////////////////

// This function does any needed initialization on the rendering

// context.

[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]void[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] SetupRC()

{

[/size][/font][/size][/font][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"]// Black background

[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

}

?

[/size][/font][/size][/font][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"]///////////////////////////////////////////////////////////////////////

// Called to draw scene

[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]void[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] RenderScene([/size][/font][/size][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]void[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"])

{

GLubyte *pImage = NULL;

GLint iWidth, iHeight, iComponents;

GLenum eFormat;



[/size][/font][/size][/font][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"]// Clear the window with current clearing color

[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]glClear(GL_COLOR_BUFFER_BIT);



[/size][/font][/size][/font][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"]// Targa's are 1 byte aligned

[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

[/size][/font][/size][/font][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"]// Load the TGA file, get width, height, and component/format information

[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]pImage = gltLoadTGA([/size][/font][/size][/font][font="Consolas"][size="2"][color="#a31515"][font="Consolas"][size="2"][color="#a31515"][font="Consolas"][size="2"][color="#a31515"]"fire.tga"[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"], &iWidth, &iHeight, &iComponents, &eFormat);



[/size][/font][/size][/font][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"]// Use Window coordinates to set raster position

[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]glRasterPos2i(0, 0);



[/size][/font][/size][/font][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"]// Draw the pixmap

[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"][/size][/font][/size][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]if[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"](pImage != NULL)

glDrawPixels(iWidth, iHeight, eFormat, GL_UNSIGNED_BYTE, pImage);



[/size][/font][/size][/font][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"]// Don't need the image data anymore

[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]free(pImage);



[/size][/font][/size][/font][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"]// Do the buffer Swap

[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]glutSwapBuffers();

}

?

[/size][/font][/size][/font][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"]//////////////////////////////////////////////////////////////

// For this example, it really doesn't matter what the

// projection is since we are using glWindowPos

[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]void[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] ChangeSize([/size][/font][/size][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]int[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] w, [/size][/font][/size][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]int[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] h)

{

[/size][/font][/size][/font][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"]// Prevent a divide by zero, when window is too short

[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"][/size][/font][/size][/font][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"]// (you cant make a window of zero width).

[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"][/size][/font][/size][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]if[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"](h == 0)

h = 1;

glViewport(0, 0, w, h);



[/size][/font][/size][/font][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"]// Reset the coordinate system before modifying

[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]glMatrixMode(GL_PROJECTION);

glLoadIdentity();



[/size][/font][/size][/font][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"]// Set the clipping volume

[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]gluOrtho2D(0.0f, (GLfloat) w, 0.0, (GLfloat) h);



glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

}

[/size][/font][/size][/font][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"][font="Consolas"][size="2"][color="#008000"]/////////////////////////////////////////////////////////////

// Main program entrypoint

[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]int[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] main([/size][/font][/size][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]int[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] argc, [/size][/font][/size][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]char[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]* argv[])

{

glutInit(&argc, argv);

glutInitDisplayMode(GLUT_RGB | GL_DOUBLE);

glutInitWindowSize(512 ,512);

glutCreateWindow([/size][/font][/size][/font][font="Consolas"][size="2"][color="#a31515"][font="Consolas"][size="2"][color="#a31515"][font="Consolas"][size="2"][color="#a31515"]"OpenGL Image Loading"[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]);

glutReshapeFunc(ChangeSize);

glutDisplayFunc(RenderScene);



SetupRC();

glutMainLoop();

[/size][/font][/size][/font][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"][font="Consolas"][size="2"][color="#0000ff"]return[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"] 0;

}

[/source]



[/size][/font][/size][/font][/size][/font][/size][/font]

Share this post


Link to post
Share on other sites
It looks like you aren't linking to the OpenGL Toolkit's library. See that function it's talking about there? gltLoadTGA? The header file you are including (Common/GLTools.h most likely) is telling the compiler that the function exists, and what it looks like, but not what it is or what it does. That's what the library does. However, if you don't link to the library, the compiler doesn't ever know how it's defined, so it fails to compile your code because it doesn't know what to do.

I don't know what the OpenGL Toolkit is though... is that a custom project/library?

Share this post


Link to post
Share on other sites
It looks like glTools is the framework used in the OpenGL Superbible. gltLoadTGA() appears to be a problem function. Googling it returned a couple pages that said it builds fine as C code, but causes this error when building C++ code. The generally offered solution is to use a different library for image loading, such as DevIL, or roll your own.

Another possible alternative would be to snag the source from the Superbible website or googlecode repository and add the glTools source to your project. That may create other problems, though, and may not even be a viable solution. I tried to find the source file defining the function to see if you could just add that, but googlecode and my phone don't play well together.

Share this post


Link to post
Share on other sites
If you are entirely sure you are linking it properly in your project settings, and you've tried building it as a C program and adding the [font="'Courier New"]extern "C"[/font] part SiCrane recommended, you can always give [url="http://www.boost.org/"]Boost's[/url] [url="http://www.boost.org/doc/libs/1_47_0/libs/gil/doc/index.html"]Generic Image Library[/url]. It might be overkill for something like this though, and I don't know how easy it is to get a loaded image into an OpenGL texture, so you can also try DevIL like yckx recommended, or you can also try [url="http://www.lonesock.net/soil.html"]SOIL[/url], though it's been so long since that project has been updated that I'd be tempted to just write my own code and use SOIL as a guide.


If you aren't 100% sure how to compile it as a C program or how to use [font="'Courier New"]extern "C"[/font], now is a good time to ask. Good luck!

Share this post


Link to post
Share on other sites
[quote name='phil67rpg' timestamp='1317940290' post='4869914']
how do I implement c using vs 2010
[/quote]
If you're asking how to compile a file as a C source file, then the easiest way is to give it a .c file extension.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this