librarys hurt me in ways you cannot imagine

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
spirit bomb!
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 17
Joined: Wed Jan 06, 2010 11:28 pm

librarys hurt me in ways you cannot imagine

Post by spirit bomb! »

Hello everyone,

So I am trying to make a simple level editor int dark gdk. All it does is translate what is on the screen and make it into a txt file.
When i started playing around with txt files it started to break on me. Here is the visual studio build output:

>libcpmtd.lib(xdebug.obj) : warning LNK4098: defaultlib 'libcmt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
1>Main.obj : error LNK2019: unresolved external symbol "public: __thiscall Obstacle::Obstacle(void)" (??0Obstacle@@QAE@XZ) referenced in function "void __cdecl DarkGDK(void)" (?DarkGDK@@YAXXZ)
1>Main.obj : error LNK2019: unresolved external symbol "public: __thiscall Obstacle::~Obstacle(void)" (??1Obstacle@@QAE@XZ) referenced in function "void __cdecl DarkGDK(void)" (?DarkGDK@@YAXXZ)
1>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)
1>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)
1>Debug\Edit.exe : fatal error LNK1120: 4 unresolved externals
1>Build log was saved at "file://c:\Documents and Settings\steve\My Documents\Visual Studio 2008\Projects\Edit\Edit\Debug\BuildLog.htm"
1>Edit - 5 error(s), 12 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I was playing around with my "project > properties > linker" and while there i used NODEFAULTLIB and played around alot, but cannot figure out the problem.

The first two errors may be due to my lack of constructor/destructors to my Obstacle class
The others are just killing me.

Anyone who can point me in the correct direction will be considered a God by me.
Any and all help is extremely appreciated!

Thank you much, and i'll post a vid of the level editor if anyone would like to see it (Assuming i can get it to run).
circular reasoning works because circular reasoning works because circular reasoning works because circular reasoning works because
circular reasoning works because circular reasoning works because circular reasoning works because circular reasoning works because
User avatar
LeonBlade
Chaos Rift Demigod
Chaos Rift Demigod
Posts: 1314
Joined: Thu Jan 22, 2009 12:22 am
Current Project: Trying to make my first engine in C++ using OGL
Favorite Gaming Platforms: PS3
Programming Language of Choice: C++
Location: Blossvale, NY

Re: librarys hurt me in ways you cannot imagine

Post by LeonBlade »

That's what I love about Xcode!
All I got to do is just add the Framework, dylib or whatever library I need and I'm good to go :D
No need for linkers etc.

But... I guess this doesn't help you at all... :roll:
There's no place like ~/
Live-Dimension
Chaos Rift Junior
Chaos Rift Junior
Posts: 345
Joined: Tue Jan 12, 2010 7:23 pm
Favorite Gaming Platforms: PC - Windows 7
Programming Language of Choice: c++;haxe
Contact:

Re: librarys hurt me in ways you cannot imagine

Post by Live-Dimension »

lmao.i *HATE* linker errors.
1>Main.obj : error LNK2019: unresolved external symbol "public: __thiscall Obstacle::Obstacle(void)" (??0Obstacle@@QAE@XZ) referenced in function "void __cdecl DarkGDK(void)" (?DarkGDK@@YAXXZ)
"Main.obj" pretty much means Main.cpp

An unresolved external symbol pretty much means you've defined an say an type/function/etc inside an include file, and used it in the cpp file, but haven't defined it in the cpp file. The compiler is smart enough to know what said type/function is thanks to the include, but the linker doesn't catch on. So basically you have to prototype? the function in the include, and define it in the source cpp file.

Errors 1 and 2 are the same. Fixing them possibly will remove the other two linker errors, as c++ errors have a fantastic ability to cascade and generate more errors.

If it doesn't work, please post the c++/include files =]
Image
User avatar
spirit bomb!
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 17
Joined: Wed Jan 06, 2010 11:28 pm

Re: librarys hurt me in ways you cannot imagine

Post by spirit bomb! »

Aight so those first two errors were easy enough to fix. All I did was comment out the constructor + destructor in my Obstacle.h file ( //~Obstacle(void); )

So now im down to.....

1>libcpmtd.lib(xdebug.obj) : warning LNK4098: defaultlib 'libcmt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
1>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)
1>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)
1>Debug\Edit.exe : fatal error LNK1120: 2 unresolved externals

i;m not sure what you mean by include file, but...

#include "DarkGDK.h"
#include "Obstacle.h"
#include <string>
#include "stdio.h"
#include <sstream>

#include <stdlib.h>

using namespace std;

is this what you mean?
I have also played around with the run time library, but that turned out to be a crapshoot.
circular reasoning works because circular reasoning works because circular reasoning works because circular reasoning works because
circular reasoning works because circular reasoning works because circular reasoning works because circular reasoning works because
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: librarys hurt me in ways you cannot imagine

Post by avansc »

Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
User avatar
spirit bomb!
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 17
Joined: Wed Jan 06, 2010 11:28 pm

Re: librarys hurt me in ways you cannot imagine

Post by spirit bomb! »

http://forum.thegamecreators.com/?m=for ... 22531&b=22

Oh my, someone with the same problem, and no solution :( :(
circular reasoning works because circular reasoning works because circular reasoning works because circular reasoning works because
circular reasoning works because circular reasoning works because circular reasoning works because circular reasoning works because
User avatar
spirit bomb!
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 17
Joined: Wed Jan 06, 2010 11:28 pm

Re: librarys hurt me in ways you cannot imagine

Post by spirit bomb! »

AVANSC, thank you much!

I now got no errors and it runs. but it does give me a wierd runtime error...

The screen goes black + unresponsive.

i debugged it and it would seem that my global dynamically created array of instance objects seems to malfunction.
It would seem that the "new" operator is messed up some how and it takes me into disassembly.
It NEVER did this before, and i know that this works because i used 4 different object arrays in my other project.

Here is a little snippet...

Obstacle *obstacle;

void DarkGDK ( void )
{
dbOpenToRead( 1 , "LevelData.txt");
dbOpenToWrite( 2 ,"LevelData.txt");

obstacle = new Obstacle[ObstacleMax]; //debugging dies here
circular reasoning works because circular reasoning works because circular reasoning works because circular reasoning works because
circular reasoning works because circular reasoning works because circular reasoning works because circular reasoning works because
Live-Dimension
Chaos Rift Junior
Chaos Rift Junior
Posts: 345
Joined: Tue Jan 12, 2010 7:23 pm
Favorite Gaming Platforms: PC - Windows 7
Programming Language of Choice: c++;haxe
Contact:

Re: librarys hurt me in ways you cannot imagine

Post by Live-Dimension »

It's generally regarded as a bad idea to differentiate different names/types/etc by capitals only, as it can be confusing later on to you and definitely other programmers. you also don't need to use void as a function parameter, ie,

//exactly the same. I assume the compiler inserts void as it compiles.
void DarkGDK()
void DarkGDK(void)

As for your freeze......
Aight so those first two errors were easy enough to fix. All I did was comment out the constructor + destructor in my Obstacle.h file ( //~Obstacle(void); )
obstacle = new Obstacle[ObstacleMax]; //debugging dies here
Were those constructors perhaps needed for something? It's "OK" to not supply any constructors as the compiler generates empty constructors/destructors anyway.

The only way I know how to make arrays is like this.

Code: Select all

int myArray[5];
myArray[0] = 1;
myArray[2] = 1337;
//etc etc
Judging by the above example, I'd assume that you need to do this (or similar).

Code: Select all

Obstacle *obstacle[ObstacleMax];
I'm not a c++ lord, hell I'm still muddling my way through my first basic game engine (though I'm doing well on it) so someone else may/should be able to help better.

Good luck!
Image
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: librarys hurt me in ways you cannot imagine

Post by dandymcgee »

spirit bomb! wrote:
Obstacle *obstacle;

void DarkGDK ( void )
{
dbOpenToRead( 1 , "LevelData.txt");
dbOpenToWrite( 2 ,"LevelData.txt");

obstacle = new Obstacle[ObstacleMax]; //debugging dies here
For some reason that doesn't look right..

Code: Select all

Obstacle *obstacle[ObstacleMax];

void DarkGDK ( void )
{
	dbOpenToRead( 1 , "LevelData.txt");
	dbOpenToWrite( 2 ,"LevelData.txt");	

	obstacle = new Obstacle[ObstacleMax];
That might work?
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
Bakkon
Chaos Rift Junior
Chaos Rift Junior
Posts: 384
Joined: Wed May 20, 2009 2:38 pm
Programming Language of Choice: C++
Location: Indiana

Re: librarys hurt me in ways you cannot imagine

Post by Bakkon »

I'm assuming obstacle is a class and not just a datatype. Might want to try like this.

Code: Select all

Obstacle** obstacles;

void DarkGDK ( void )
{
   dbOpenToRead( 1 , "LevelData.txt");
   dbOpenToWrite( 2 ,"LevelData.txt");   

   obstacles = new Obstacle*[ObstacleMax];

   for(int i = 0; i < ObstableMax; i++)
      obstacles[i] = new Obstacle();
}
Post Reply