Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Linking Errors

Author
Message
Anastasia
15
Years of Service
User Offline
Joined: 17th Sep 2009
Location:
Posted: 17th Sep 2009 23:22
Hi,

I teach C++ at a small university. We've recently begun using DarkGDK to make graphical programs.

I wrote the following program in standard C++, and it compiles and works fine. Then I copied the code into a DarkGDK 2D project. I rewrote all of the output statements to DarkGDK output statements, and I changed the include files. Now the project is giving me linking errors for unresolved external symbols. The only thing that I can think of is that some of the constructs I'm using are not available in DarkGDK projects.

Any help would be appreciated!
Thanks,
Anastasia

Code:
#include "DarkGDK.h"
#include <queue>
using namespace std;

struct treeNode
{
int planet;
treeNode * left;
treeNode * right;
};

typedef treeNode* treeNodePtr;

void buildChain(treeNodePtr& cur, int planet, int maxPlanets)
{
if(planet <= maxPlanets)
{
cur = new treeNode;
cur->planet = planet;
planet++;
cur->left = 0;
cur->right = 0;
buildChain(cur->left, planet, maxPlanets);
}
}

int choose(int n, int k, int planet, int maxPlanets, treeNodePtr& cur)
{
if((k == 0) || (k==n))
{
if(k == n)
{
if(planet <= maxPlanets)
{
buildChain(cur, planet, maxPlanets);
}

}
return 1;
}
else if(k > n)
return 0;
else
{
cur = new treeNode;
cur->planet = planet;
cur->left = 0;
cur->right = 0;

return choose(n-1, k-1, planet+1, maxPlanets, cur->left) + choose(n-1, k, planet+1, maxPlanets, cur->right);
}
}

void printQ(queue<int> pq)
{
char printstring[100];
char tempstring[1];
while(pq.empty() == false)
{
sprintf(tempstring, "%d", pq.front());
strcat(printstring, tempstring);
pq.pop();
}
dbPrint(printstring);
}

void printTree(treeNodePtr root, queue<int> printqueue, int size)
{
if(root != 0)
{
printTree(root->right, printqueue, size);
printqueue.push(root->planet);
printTree(root->left, printqueue, size);
}
else
{
if(printqueue.size() == size)
{
printQ(printqueue);
}
}
}

void DarkGDK()
{
treeNodePtr root = 0;
int numPlanets, numVisit;
numPlanets = 5;
numVisit = 3;
int numCombinations;
queue<int> printqueue;

numCombinations = choose(numPlanets, numVisit, 1, numPlanets, root);
printTree(root, printqueue, numVisit);

}

Compile results:
Compiling...
Main.cpp
Linking...
libcpmtd.lib(xdebug.obj) : warning LNK4098: defaultlib 'libcmt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
Main.obj : error LNK2019: unresolved external symbol __CrtDbgReportW referenced in function "public: __thiscall std::_Deque_const_iterator,1>::_Deque_const_iterator,1>(unsigned int,class std::_Container_base_secure const *)" (??0?$_Deque_const_iterator@HV?$allocator@H@std@@$00@std@@QAE@IPBV_Container_base_secure@1@@Z)
libcpmtd.lib(stdthrow.obj) : error LNK2001: unresolved external symbol __CrtDbgReportW
libcpmtd.lib(xdebug.obj) : error LNK2019: unresolved external symbol __malloc_dbg referenced in function "void * __cdecl operator new(unsigned int,struct std::_DebugHeapTag_t const &,char *,int)" (??2@YAPAXIABU_DebugHeapTag_t@std@@PADH@Z)
libcpmtd.lib(xdebug.obj) : error LNK2019: unresolved external symbol __free_dbg referenced in function "void __cdecl operator delete(void *,struct std::_DebugHeapTag_t const &,char *,int)" (??3@YAXPAXABU_DebugHeapTag_t@std@@PADH@Z)
Debug\Spock3.exe : fatal error LNK1120: 3 unresolved externals
Bran flakes91093
16
Years of Service
User Offline
Joined: 13th Sep 2008
Location: Crazy Land
Posted: 17th Sep 2009 23:50
Go to [Project]->[<Project Name> Properties...]->[+](Configuration Properties)->[+](C/C++)->(Code Generation) and change the Runtime Library to /MT instead of /MTd.

Your_Health = (My_Mood == HAPPY) ? 100 : NULL;
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 18th Sep 2009 00:42
@Anastasia - DarkGDK, unfortunately is not compiled and linked with a debug library(although v7.4 comes with a debug folder, i havent tried linking the libs in there so cant say if they work or not) if compiled and linked in release mode, so anytime you link to DarkGDK you need to tell it to use non-debug libs(which does kind of defeat the purpose of debugging in the first place, though you can still use the basics, alot of debug functions wont work, and you cannot have _DEBUG or DEBUG defined as a preprocessor it will generate link errors)

Also, on another note, im not sure of the code you posted above is complete or not(im assuming not) as it will not run in the state it is in... DarkGDK creates it's own window and registers it's own window class and manages its own message pump(can only get at it with CallWindowProc) and creates the directX device for you.

At the very least you main "void DarkGDK()" block should have a skeleton like this :



Have a look through the examples if you arent sure of how its all working, being a teacher of C++ you should be able to follow it all quite easily

If it ain't broke.... DONT FIX IT !!!
Anastasia
15
Years of Service
User Offline
Joined: 17th Sep 2009
Location:
Posted: 18th Sep 2009 17:40
Bran flakes91093 - That fixed it! Thanks!

Anastasia

Login to post a reply

Server time is: 2024-11-20 15:34:43
Your offset time is: 2024-11-20 15:34:43