Sign in to follow this  
xg0blin

Just switched to vc++ 7.0 and having problems

Recommended Posts

I just switched compilers. I'm getting unresolved external symbols, though they very clearly are defined. For two days I've been trying to figure this out. I have my bmp.h file included, when I use the function (called create_texture) it highilights what the arguments are and everything. The prototpye is: void create_texture(char *, unsigned int *, unsigned int); The error I'm getting is: unresolved external symbol void _cdecl create_texture(char *, unsigned int *, unsigned int); The header is clearly included. I even included it in my implementation file to be sure. Visual studio even highlights the argment list in the file for me (it doesn't do that unless it's defined right?). What is visual studio's problem? Here, how about a little code snippet. This is my model loading code
#ifndef MD2Model_h
#define MD2Model_h

#include "bmp.h"
#include <GL/glut.h>
#include <fstream> 
#include <string>
#include <cmath>
using namespace std;


struct MD2Header
{
	int Identity;
	int Version;
	int SkinWidth;
	int SkinHeight;
	int FrameSize;
	int NumSkins;
	int NumVerts;
	int NumTexCoords;
	int NumTriangles;
	int NumGLCommands;
	int NumFrames;
	int OffsetSkins;
	int OffsetTexCoords;
	int OffsetTriangles;
	int OffsetFrameData;
	int OffsetGLCommands;
	int OffsetEnd;
};

struct MD2Vertex
{
	unsigned char Vertex[3];
	unsigned char LightNormalIndex; // Not used.
};

struct MD2Frame
{
	float     Scale[3];
	float     Translate[3];
	char      Name[16];
	MD2Vertex *Vertices;
};

struct MD2Triangle
{
	short VertexIndex[3];
	short TextureIndex[3];
};

struct MD2TextureCoordinate
{
	short s;
	short t;
};

struct MD2GLCommand
{
	float s;
	float t;
	int VertexIndex;
};

struct RealioVerts
{
	float Verts[3];
};

struct RealioTexCoords
{
	float s;
	float t;
};

class MD2Model
{
	public:
		MD2Model();
		~MD2Model();
		// Basic Model Functions
		bool LoadModel(string);
		bool GetMD2FileStream(string);
		bool MD2FileStream_IsOpen(void);
		bool ReadMD2Header(void);
		bool WriteMD2Header(string);
		void GetRealVerts(void);
		void GetRealTexCoords(void);
		void DisplayModel(void);
		void DoNormals(float *, float *, float *);

		// Skin Stuff
		bool AllocateSkinMemory(void);
		bool LoadSkinInfo(void);
		bool WriteSkinInfo(string);

		// Frame Stuff
		bool AllocateFrameMemory(void);
		bool LoadFrameInfo(void);
		bool WriteFrameInfo(string);

		// Texture Stuff
		bool AllocateTextureMemory(void);
		bool LoadTextureInfo(void);
		bool WriteTextureInfo(string);

		// Triangle Stuff
		bool AllocateTriangleMemory(void);
		bool LoadTriangleInfo(void);
		bool WriteTriangleInfo(string);

		// GL Command Stuff
		bool AllocateGLCommandMemory(void);
		bool LoadGLCommandInfo(void);
		bool WriteGLCommandInfo(string);

  private:
		ifstream MD2File;
		MD2Header hdr;
		char **SkinNames;
		MD2Frame *FrameData;
		MD2TextureCoordinate *TexCoords;
		MD2Triangle *Triangles;
		RealioVerts     *RealVerts;
		RealioTexCoords *RealTexCoords;
		unsigned int textures[1];
};

#endif

Here is a little part of the implementation. The part where I call the create_texture function.
#include "MD2Model.h"

bool MD2Model::LoadModel(string FileName)
{
	if(this->GetMD2FileStream(FileName) && this->ReadMD2Header())
	{
			this->WriteMD2Header("Header.txt");
			if(this->AllocateSkinMemory())
			{
				if(this->LoadSkinInfo())
				{
					this->WriteSkinInfo("Skins.txt");
				}
			}
			if(this->AllocateFrameMemory())
			{
				if(this->LoadFrameInfo())
				{
					this->WriteFrameInfo("Frames.txt");
				}
			}
			if(this->AllocateTextureMemory())
			{
				if(this->LoadTextureInfo())
				{
					this->WriteTextureInfo("Texutre.txt");
				}
			}
			if(this->AllocateTriangleMemory())
			{
				if(this->LoadTriangleInfo())
				{
					this->WriteTriangleInfo("Triangle.txt");
				}
			}
			GetRealVerts();
			GetRealTexCoords();

			create_texture("Fudd.bmp", textures, 0);
			return true;
	}
	else
		return false;
}

Here is bmp.h
#ifndef bmp_h
#define bmp_h

#include "xg0_image.h"

#define BMP_RGB			0
#define BMP_RLE8		1
#define BMP_RLE4		2
#define BMP_BITFIELDS	3

struct BMPFileHeader
{
	ushort	Identifier;
	ulong	Size;
	ushort	Reserved1;
	ushort	Reserved2;
	ulong	OffsetData;
};

struct BMPInfoHeader
{
	ulong	Size;
	ulong	Width;
	slong	Height;
	ushort	ColorPlanes;
	ushort	Depth;
	ulong	Compression;
	ulong	ImageSize;
	ulong	HPixelsPerMeter;
	ulong	VPixelsPerMeter;
	ulong	ColorsUsed;
	ulong	ColorsImportant;
};

struct RGBQuad
{
	ubyte Red;
	ubyte Green;
	ubyte Blue;
	ubyte Fat;
};

int	LoadBMP				  (const char *, struct xg0_Image*);
int	ParseBMPHeader		  (FILE *, struct BMPFileHeader *);
int	ParseBMPInfo		  (FILE *, struct BMPInfoHeader *);
int LoadBMPPalette		  (FILE *, struct RGBQuad *, ulong);
int LoadBMPData			  (FILE *, ulong, slong, ushort, ubyte *);
int LoadBMPRLE8Data		  (FILE *, ulong, slong, ushort, ubyte *);
int LoadBMPRLE4Data		  (FILE *, ulong, slong, ushort, ubyte *);
int LoadBMP16BitData      (FILE *, ulong, slong, ushort, ubyte *, ushort []);
int LoadBMP32BitData      (FILE *, ulong, slong, ushort, ubyte *, ulong  []);
int Uncompress1BitBMP	  (ubyte *, ubyte *, struct RGBQuad *, ulong, ulong);
int Uncompress4BitBMP	  (ubyte *, ubyte *, struct RGBQuad *, ulong, ulong);
int Uncompress8BitBMP	  (ubyte *, ubyte *, struct RGBQuad *, ulong, ulong);
int Load16BitBitMasks     (FILE *, ushort[]);
int Load32BitBitMasks     (FILE *, ulong []);

void create_texture(char *, unsigned int *, unsigned int);

#endif

What is the deal? It's very clearly included. That'll teach me to upgrade.

Share this post


Link to post
Share on other sites
the compiler error is "unresolved external" which means the linker cant find it in any of the obj/lib files its linking together. is the create_texuture func implemented in bmp.cpp or elsewhere?

also if you've just upgraded the project from a vc6 one, do a full rebuild if you havent alread, it might be trying to link an obj thats from vc6.

Share this post


Link to post
Share on other sites
It's implemented in bmp.c. I changed it to bmp.cpp since all the other files are .cpp. This is pretty old code here.

UPDATE: Heh. Instead of doing clean and then build again, I just did a rebuild solution and it worked. I don't get it.

Share this post


Link to post
Share on other sites
Quote:
Original post by xg0blin
UPDATE: Heh. Instead of doing clean and then build again, I just did a rebuild solution and it worked. I don't get it.


thats just wierd. i thought at first that cleaning a build just cleans out the obj and other intermediate files, but i tested it and it cleans out the lot, including the ouput exe. ah well, at least its working now...

Share this post


Link to post
Share on other sites
Quote:
Original post by xg0blin
It's implemented in bmp.c. I changed it to bmp.cpp since all the other files are .cpp. This is pretty old code here.

UPDATE: Heh. Instead of doing clean and then build again, I just did a rebuild solution and it worked. I don't get it.


If it was in bmp.c, and something.cpp included the .h file then this occured:


header interpreted as function with standard calling convention, while the function was interpreted as a c function call.

void create_texture(char *, unsigned int *, unsigned int);
vs.
_cdecl void create_texture(char *, unsigned int *, unsigned int);

you could have wrapped your prototype in an extern "C" {} block, I think.

Share this post


Link to post
Share on other sites
So far visual c++ 7 is pissing me off. I just got another error that should not be.

I have this class:

class XGModel
{
public:
XGModel();
XGModel(string, string);
~XGModel();
bool LoadModel(string, string);
bool DisplayModel(unsigned int FrameNumber);
bool ReleaseModel(void);
bool WriteModel(string);

protected:
void CalculateNormals(void);

private:
unsigned int NumVerticesPerFrame_;
unsigned int NumTexCoords_;
unsigned int NumFaces_;
unsigned int NumFrames_;
string SkinName_;
bool IsLoaded_;
unsigned int Texture_[1]; // Each model gets a single texture of its own

XGTexCoord *TexCoords_; // There should only be one list of texture coordinates
XGFrame *Frames_;
XGFace *Faces_;
XGVertex *Normals_;
XGAnimation *Animations_;

}



Here is part of the implementation:

#include "XGM.h"

XGModel::XGModel(void)
{
NumVerticesPerFrame_ = 0;
NumTexCoords_ = 0;
NumFaces_ = 0;
NumFrames_ = 0;
IsLoaded_ = false;

TexCoords_ = NULL;
Frames_ = NULL;
Faces_ = NULL;
Normals_ = NULL;
Animations_ = NULL;
}



It gives me an error saying this constructor can't have a return type. This constructor clearly HAS no return type, so what the hell is with the error? None of the other constructors failed, and they are done in pretty much the same way. ARGH.

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