Public Group

Unresolved external symbol?

Recommended Posts

Hi

Having coded alot, i still get stuck on these things sometimes. I've restarted an old project so I needed to clean it up, fixed paths etc before it could compile. I still have one compile error:

Error	1	error LNK2019: unresolved external symbol "public: void __thiscall gameInventory::setSingleSlot(class int2)" (?setSingleSlot@gameInventory@@QAEXVint2@@@Z) referenced in function "public: __thiscall gameInventoryMaster::gameInventoryMaster(void)" (??0gameInventoryMaster@@QAE@XZ)

C:\Dropbox\PROJECT\code\games\racing\source\gameMaster.obj

May it be a circular include or something? The function "setsingleSlot" is defined in a file called "inventory.h" which i dont have any references to in my project, so im a little stuck here.

Any ideas?
Happy holidays ya'all!

Share on other sites
18 minutes ago, suliman said:

Any ideas?

There is an argument-less constructor in the class gameInventoryMaster within which the method gameInventory::setSingleSlot is invoked. So look out for that.

24 minutes ago, suliman said:

May it be a circular include or something?

More an indirect include, i.e. an include in an included file or an include in an implementation file.

Share on other sites

Cool! Commenting out that call allows for it to compile.

But what can be wrong here? That file (with the constructor for gameInventoryMaster) is included in all my project and those work without commenting out the call togameInventory::setSingleSlot(). Why is it now not allowed?

I moved the body of the contructor (of gameInventoryMaster) to the cpp file (from the h file) and now all projects compile. So im confused, what could have have done here?

Edited by suliman

Share on other sites

Firstly, this is a linker error, not a compiler error, so the problem is in what is being passed to the linker not the compiler. Secondly, when you get a 'unresolved external symbol' error the linker is trying to connect the reference to the setSingleSlot function in the constructor code to the actual setSingleSlot function, but can't find said function. As for why moving the constructor body to the cpp file fixed the issue, does gameMaster.cpp contain code for the gameInventoryMaster class?

Share on other sites

yes it does. I continued to clean up and now it works (even with the body in the h-file).

I think I had a reference to an old version of it that was local and not the standardized version i now use (#include "file.h" instead of #include <file.h>).

This is one of my big problems with C/C++. It's so easy to get stuck on code administration (linking, include order, circle reference etc) It takes time (especially when reviving an old project that had a slightly different code architecture).

1. 1
2. 2
3. 3
Rutin
18
4. 4
JoeJ
14
5. 5

• 14
• 9
• 23
• 9
• 32
• Forum Statistics

• Total Topics
632625
• Total Posts
3007508
• Who's Online (See full list)

There are no registered users currently online

×

Important Information

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!