I get the following linker error when trying to run my code
menu.obj : error LNK2001: unresolved external symbol “int __cdecl loadTGA(char *,int)” (?loadTGA@@YAHPADH@Z)
Debug/menu_background.exe : fatal error LNK1120: 1 unresolved externals
here is my code:-
#include “tga.h”
#include <cstdlib> // standard definitions
#include <iostream> // C++ I/O
#include <cstdio> // C I/O (for sprintf)
#include <cmath>
#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <gl/glut.h>
#include <gl/glaux.h>
#include <stdio.h>
#define APP_NAME “menu + background”
using namespace std; // make std accessible
int winW = 800; /* window width /
int winH = 600; / window height */
int d=1;
//-----------------------------------------------------------------------
void myinit(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glColor3f(0.0f, 0.0f, 0.0f);
glPointSize(4.0);
glMatrixMode(GL_PROJECTION);
gluOrtho2D(0.0, 800.0, 0.0, 600.0);
glEnable(GL_FLAT);
glEnable (GL_TEXTURE_2D);
if (loadTGA (“sky.tga”, 13) != 1)
printf("TGA error
");
}
//-----------------------------------------------------------------------
void output(int x, int y, char *string) //this function is used to output the text that
{ //we want in the position we want using x , y
int len, i; //coordinates
glRasterPos2f(x, y);
len = (int) strlen(string);
for (i = 0; i < len; i++)
{
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, string);
}
}
//-----------------------------------------------------------------------
void menu (void)
{
d=1;
glColor3f(1.0, 1.0, 1.0);
output(350, 440, “-------”);
output(330, 400, “START GAME”); //all text to be displayed in the menu
output(335, 350, “CONTROLS”);
output(355, 300, “STORY”);
output(365, 250, “EXIT”);
output(350, 210, “-------”);
glEnd();
glFlush();
}
//-----------------------------------------------------------------------
void start(void)
{
glClear(GL_COLOR_BUFFER_BIT); //link to start of main game code
d=4;
}
//-----------------------------------------------------------------------
void controls(void)
{
d=2;
glColor3f(0.6, 0.6, 0.6);
output(115, 440, “* TO MAKE THE PLANE ACCELERATE PRESS THE UP ARROW ");
output(115, 400, " TO MAKE THE PLANE PITCH UP PRESS THE RIGHT ARROW "); //all controls text
output(110, 350, " TO MAKE THE PLANE DIVE DOWN PRESS THE LEFT ARROW ");
output(220, 300, " TO FIRE PRESS THE SPACE BAR ");
glColor3f(1.0, 1.0, 1.0);
output(365, 200, “BACK”);
glEnd();
glFlush();
}
//-----------------------------------------------------------------------
void story(void)
{
d=3;
glColor3f(0.6, 0.6, 0.6);
output(115, 440, " TO MAKE THE PLANE ACCELERATE PRESS THE UP ARROW ");
output(115, 400, " TO MAKE THE PLANE PITCH UP PRESS THE RIGHT ARROW "); //story text
output(110, 350, " TO MAKE THE PLANE DIVE DOWN PRESS THE LEFT ARROW ");
output(220, 300, " TO FIRE PRESS THE SPACE BAR *”);
glColor3f(1.0, 1.0, 1.0);
output(365, 200, “BACK”);
glEnd();
glFlush();
}
//----------------------------------------------------------------------- keyboard function can be deleted
void myKeyboard(unsigned char c, int x, int y) // keyboard callback
{
switch ©
{ // c is the key that is hit
case ‘w’:
d=1;
menu();
break;
}
}
//-----------------------------------------------------------------------
void myMouse(int b, int s, int x, int y) // mouse click callback
{
if (s == GLUT_DOWN)
{
cout << “Mouse click detected at coordinates x=” //info displayed to dos box can go
<< x << " and y=" << y << endl;
}
cout << "d= "<< d << endl;
if (d==1)
{
if (x>=330 && x<=450 && y>=185 && y<=200) //start
{
glClear(GL_COLOR_BUFFER_BIT);
start();
}
if (x>=335 && x<=440 && y>=235 && y<=250) //controls
{
glClear(GL_COLOR_BUFFER_BIT);
controls();
}
if (x>=335 && x<=420 && y>=285 && y<=300) //story
{
glClear(GL_COLOR_BUFFER_BIT);
story();
}
if (x>=365 && x<=405 && y>=335 && y<=350) //exit
{
exit(1);
}
}
if (d==2)
{
if (x>=365 && x<=405 && y>=385 && y<=400) //back(controls)
{
glClear(GL_COLOR_BUFFER_BIT);
menu();
}
}
if (d==3)
{
if (x>=365 && x<=405 && y>=385 && y<=400) //back(story)
{
glClear(GL_COLOR_BUFFER_BIT);
menu();
}
}
}
//-----------------------------------------------------------------------
void background (void)
{
glBindTexture (GL_TEXTURE_2D, 13); /* bind to our texture, has id of 13 */
glBegin (GL_POLYGON);
glTexCoord2f (-400,-300); /* lower left corner of image /
glVertex3f (-400, -300, 0);
glTexCoord2f (400, -300); / lower right corner of image /
glVertex3f (400, -300, 0);
glTexCoord2f (400, 300); / upper right corner of image /
glVertex3f (400, 300, 0);
glTexCoord2f (-400, 300); / upper left corner of image */
glVertex3f (-400, 300, 0);
glEnd ();
}
//-----------------------------------------------------------------------
void maindisplay(void)
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
background();
menu();
glutSwapBuffers();
glFlush();
}
//-----------------------------------------------------------------------
void main (int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (winW,winH);
glutCreateWindow (APP_NAME);
glutDisplayFunc(maindisplay);
myinit();
glutMouseFunc(myMouse);
glutKeyboardFunc(myKeyboard);
glutMainLoop();
}
if anyone can help would be appreciated this is just the menu system of a game and a background image.
thx