PDA

View Full Version : DJGPP project problems



VirtualAce
05-25-2002, 02:43 PM
I've written hundreds of projects inside of the Borland and Turbo C IDEs and have never encountered this problem.

I'm trying to write a small game in DJGPP. I have several source files that I'm including in my project. They are not libraries yet, they are pure source - this allows me to modify them easily during development.

Here is my problem.


#include "svga.h"

int main(void)
{
SVGASys<COLOR16> Video;
Video.SetMode(0x111);
return 0;
}


Project window looks like this:

svga.cpp
test.cpp (the test file - see above)
keyboard.cpp


COLOR16 is typedef as unsigned short
This template class allows me to use the same class for all video modes and all bit depths.

DJGPP tells me that SVGASys<unsigned short>::SetMode() is an undefined reference. But this is hogwash because it is declared in the svga.h header file and it is defined in the svga.cpp file which is part of my project.

Now what is odd is that i'm also including my keyboard handler source code as well. Now for some reason, this code works and does not give me an undefined reference



#include "keyboard.h"
#include "svga.h"

int main(void)
{
StartKeyboard();
StopKeyboard();
return 0;
}


This works. So DJGPP is finding StartKeyboard in keyboard.h and is also linking with keyboard.cpp to create the final thing.


My question. Why on God's green earth does the first one not work but the second one does?

Incidentally if I place the main() inside of svga.cpp to test out the functions (outside of the project), it works perfect. But this seems to only work outside of a project and only on single file programs.

Theoretically if it is not linking right, then neither the keyboard example nor the SVGA example should work since the linker would not be able to find either source file. Something is seriously wrong because the keyboard example works, but the SVGA one does not. But like I said, I know my template class works because it will work when I place main() inside of the svga.cpp file.

I've tried to delete all of the .o files relating to this project and still no go. This is probably the same reason that RHIDE gives me the same error when trying to call a function in a NASM source file that is in the project.

All these files are in the DJGPP directory, but I've also tried it by creating a project in another directory. Neither method works.

Help!!!

VirtualAce
05-31-2002, 03:30 PM
Never mind I figured it out. Template's and their respective code must be in the same file.

#include "mytemplates.tpl"

Like this. Ugly way to use include files but this is how you have to do it with templates.

sean
06-04-2002, 11:08 AM
Good job on solving the problem yourself, but just for future reference, the site does have some tutorials on using DJGPP

Unregistered
06-04-2002, 03:25 PM
It was not a problem with DJGPP, it was purely C++ related problem. I've read every thing on that site and have the entire help file in HTML format as well as text format on my drive.

sean
06-08-2002, 07:16 PM
I realize this wasn't the problem, but you know, someone should really write some guide as to all the minor differences between compilers that nobody really takes any notice of until it causes a huge problem. Who's with me?