Jump to content
  • Advertisement
Sign in to follow this  
phil67rpg

error message

This topic is 2547 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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"][color="#0000ff"][font="Consolas"][color="#0000ff"][font="Consolas"][color="#0000ff"]

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

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

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

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

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

[/font][/font][/font][font="Consolas"][font="Consolas"]

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

// This function does any needed initialization on the rendering

// context.

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

{

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

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

}

?

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

// Called to draw scene

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

{

GLubyte *pImage = NULL;

GLint iWidth, iHeight, iComponents;

GLenum eFormat;



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

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



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

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

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

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



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

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



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

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

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



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

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



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

[/font][/font][/font][font="Consolas"][font="Consolas"]glutSwapBuffers();

}

?

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

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

// projection is since we are using glWindowPos

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

{

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

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

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

h = 1;

glViewport(0, 0, w, h);



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

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

glLoadIdentity();



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

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



glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

}

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

// Main program entrypoint

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

{

glutInit(&argc, argv);

glutInitDisplayMode(GLUT_RGB | GL_DOUBLE);

glutInitWindowSize(512 ,512);

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

glutReshapeFunc(ChangeSize);

glutDisplayFunc(RenderScene);



SetupRC();

glutMainLoop();

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

}

[/source]



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

Share this post


Link to post
Share on other sites
Advertisement
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
Not other than what I just gave, above: use DevIL for TGA loading, or write your own function.

Share this post


Link to post
Share on other sites
If you are mixing C++ and C, then make sure the relevant declarations are wrapped in extern "C" on the C++ side.

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 Boost's Generic Image Library. 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 SOIL, 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
I wasn't thinking—I should have thought of wrapping the glTools headr in an extern "C" block.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!