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.
Code:
#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

Code:
#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!!!