Archived

This topic is now archived and is closed to further replies.

oxygen_728

LNK2005 Error... Cannot figure out why...

Recommended Posts

I recently zipped up my entire project and uploaded it to my website... in case you would like to look at the source code. www.oxygen728.com/brian.zip Visual Studio 2003 , Directx 9 Summer Update SDK This is one error: BrianDX error LNK2005: "protected: static long __cdecl CMesh::CreateMesh(struct IDirect3DDevice9 *,char const *,struct ID3DXMesh * &,struct IDirect3DTexture9 * * &,struct _D3DMATERIAL9 * &,unsigned long &)" (?CreateMesh@CMesh@@KAJPAUIDirect3DDevice9@@PBDAAPAUID3DXMesh@@AAPAPAUIDirect3DTexture9@@AAPAU_D3DMATERIAL9@@AAK@Z) already defined in CMesh.obj This is the other error: BrianDX fatal error LNK1169: one or more multiply defined symbols found I searched for LNK2005 on these forums, and I read all of about 40 posts from simillar problems to these. ------------------------ What do I know? 1. These linker problems started appearing when I created a new project and imported in my .cpp and .h file. I patched the other 2005 errors by including the correct .lib files in my solution settings. 2. My CreateMesh function is Prototyped in only one place, and is implemented in only one place. 3. If I change the name of CreateMesh to MyCreateMesh, the problem still exists. 4. I don''t define INITGUID thing that everybody has a problem with, I do include the dxguid.lib though in my solution settings. 5. I don''t have any global variables in my lone CInterface.h file... though several of my classes do have public variables. 6. I do have some global variables in my meshes.cpp file (This is my main) 7. This application ran fine from its original location. It originally was one of the tutorials that shipped with DIRECTX9SDK, but I got sick of clicking on 500 folders to get to my directory, so I created a new solution and imported these files. 8. Meshes.cpp is my main file with the message pump and such 9. CInterface is my only header file 10. I include 4 files in CInterface.h ... all other .cpp files include CInterface.h 11. I do have my header file beginning with #pragma once (I believe this achieves the same thing as doing the #ifdef ... #something.... header file #endif I tried that (the actual syntax) but it made no difference in my problem. 12. I can''t think of anything else at the top of my head. Thank you very much, I''ve now spend 2 hours on this error, I HIGHLY appreciate your time.

Share this post


Link to post
Share on other sites
You don''t say WHAT place you define CreateMesh in.

My guess is that you define it in a header file that gets included more than once, or possibly in a cpp file that gets included in more than one other file.

Add a #pragma message or an #error right before you define CreateMesh, and see where those messages show up -- dollars to donuts it''ll show up more than once.

Also note that the linker is telling you where it''s defined. It''s defined in CMesh.obj, and whatever file it was working on when giving that error message (which you didn''t paste).

Share this post


Link to post
Share on other sites

"You don't say WHAT place you define CreateMesh in."

Well, My Prototype is in CInterface.h ... and I define my function in CMesh.cpp. Prototype != Define right? I don't use this terminology often, sorry.



"My guess is that you define it in a header file that gets included more than once, or possibly in a cpp file that gets included in more than one other file."

My CInterface.h gets included about 8 or 9 times.. I have many .cpp files. I use CInterface.h to store the prototypes for my various classes.



"Add a #pragma message or an #error right before you define CreateMesh, and see where those messages show up -- dollars to donuts it'll show up more than once."

I'll try this as soon as possible



"Also note that the linker is telling you where it's defined. It's defined in CMesh.obj, and whatever file it was working on when giving that error message (which you didn't paste). "

Hmm, It just says BrianDX as my file. That is the name of my Solution.


[edited by - oxygen_728 on March 26, 2004 12:49:37 AM]

Share this post


Link to post
Share on other sites
The problem was right under my nose...

A CreateMesh.cpp file was created by visual studio ... for what reason, I don''t know.

Guess what was inside this file? CMesh::CreateMesh(...)

I didn''t do this... makes ya wonder doesnt it.


I thank you for your time!

Share this post


Link to post
Share on other sites