Thread: DJGPP project problems

  1. #1
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607

    DJGPP project problems

    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!!!

  2. #2
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    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.

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Good job on solving the problem yourself, but just for future reference, the site does have some tutorials on using DJGPP

  4. #4
    Unregistered
    Guest
    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.

  5. #5
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    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?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. First "big" project and having problems...
    By rabbit in forum C++ Programming
    Replies: 1
    Last Post: 02-11-2006, 09:34 PM
  2. Operating System Project
    By Pete in forum Projects and Job Recruitment
    Replies: 1
    Last Post: 07-15-2004, 09:33 AM
  3. application project
    By featherflutter in forum C++ Programming
    Replies: 2
    Last Post: 06-26-2004, 11:12 AM
  4. Please, suggest a project ….
    By Dragon227Slayer in forum C# Programming
    Replies: 1
    Last Post: 06-12-2004, 11:16 AM
  5. Please, suggest a project ….
    By Dragon227Slayer in forum Tech Board
    Replies: 1
    Last Post: 06-12-2004, 10:48 AM