-
Linking problems
I'm having problems linking with my headers.
in my game i have these files:
rpg.ccp
player.h
player.ccp
rpg and player.ccp have #include "player.h" but both have linking errors. i pretty much don't really know what to do. if it matters im using Borland.
Thanks for any and all help.
-
-
well, i don't have the files on this computer...but it's something like this
something like external blah blah player::player in RPG.OBJ
same with player::~player
hope u can understand that...
-
Have you impemeted those functions (not just declared them in the class declaration)?
-
I implemented them in player.ccp
if i could possibly get some source code of the correct way of linking or and explanation that would be great.
-
Btter to see yours first and say where your going wrong
-
well, in rpg i have this (just the related stuff to this subject)
Code:
main
{
player usr;
blah blah
return 0;
}
//player.h
class player
{
//variables and such
}
//player.ccp
player::player(arguments)
{
//function stuff
}
that probably doesn't help at all but...im trying
-
Try this
Code:
#include <iostream>
class player
{
public:
player();
};
player::player()
{
std::cout << "Player created";
}
int main(int argc, char** argv)
{
player p;
}
-
hmmm...well, i guess i could do one file. but it doesn't solve the question of why the linking doesn't work.
but thanks for ur help.
-
It should work just as well in seperate files. As long as Main.cpp and Player.cpp have Player.h then all should be well.
-
but that's what i have...
i have #include "player.h" in both of them. eh...i'll ask mi padre when he gets home
-
> rpg.ccp
> player.h
> player.ccp
You have to make sure ALL your source files are in the project, otherwise it won't know to compile them, and the linker will then complain about not being able to find definitions for everything.
From a simple command line, you would do
bcc32 player.cpp rpg.cpp
If you're using an IDE and a project, you need to achieve the same thing.
-
oh...i WOULD probably work if i did it as a project and not individual files. duh!