c++ - Linker errors even though I prevent them with #ifndef -


I suggest the linker errors that I'm not using #ifndef and #define.

1> Tijielloderkobije error Elanke 2005: "Structure TGA TGA" (? Tga @@ 3UTGA @@ A) already went defined Mukykobije 1> Tijielloderkobije : error Elanke 2005: "structure Tiajiacdder Taghader" (? Tgaheader @@ error LNK2005: "unsigned char * defined uTGAcompare" (uTGAcompare @@ 3PAEA) already main.obj 1> TGALoader.obj: error LNK2005: "unsigned 3UTGAHeader @@ a) already 1> TGALoader.obj defined main.obj four * cTGAcompare" (? cTGAcompare @@ 3PAEA) are already Fixed in main.obj 1> Link: Warning LNK4098: defaultlib 'LIBCMTD' conflict with the use of other libs; Use / NODEFAULTLIB: library

I have a header file Texture.h and tga.h from Nehe OpenGL tutorials in your project. I have

  #ifndef TGAISCOOL #define TGAISCOOL #endif  

in my tga.h file. If I include it more than once, then I get errors from the linker that I had stuck up earlier than the two texture.h, though it is in the position itself.

What's wrong?

You are not doing anything wrong with the problem that is with the Tga.h file you've got to Nehe it does header file defines four objects, which means that if you add in different translation units file will appear several times symbols for them and that is complaining about Linkkrta .

Solving the solution definitions of these objects in the Tga.cpp file.

The lines given in Tga.h should now read the definitions first

  extern TGAHeader tgaheader; Extratgiga; Exxon GLUUTUtgEmampare [12]; Extra Globe CTGA Comprehensive [12];  

Now Tga.cpp

with the original versions of these lines

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -