Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

UltimatumX

Header Files in Mingw 3.0

This topic is 5281 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In school we are using Textpad to write C++ programs and MinGW 3.0 as the compiler. We use mingw32-g++ when we compile the program in the Command prompt. My question is how do we implement header files using this setup? We usually get errors and such when trying to do the program? Future Game Desinger... Currently studying C++, Oracle, Visual Basic 6.0

Share this post


Link to post
Share on other sites
Advertisement
Create the header files as seperate files? Err, here's the kind of thing I do:

--MyClass.h--
#ifndef MYCLASS_H //include guard
#define MYCLASS_H //(prevents multiple decleration warnings)
class MyClass
{
public:
void DoSomething( void );
void DoAnotherThing( void );
};
#endif //ndef MYCLASS_H //end include guard



--MyClass.cpp--
#include "myclass.h"
void MyClass::DoSomething( void )
{
//actual code...
}
void MyClass::DoAnotherThing( void )
{
//foobar
}


Then:

g++ MyClass.cpp main.cpp otherfile.cpp -o program -lstdc++ -lSDL_main -lSDL -lOpenGL32

or the like.

Maybe if you clarify your problem? (edit: read: like, ya know, tell us what errors are popping up? For all we know the compiler is crashing XD)

I'm guessing some of them probably stem from not selecting what libraries you're linking against? (those -l____ flags).

[edited by - MaulingMonkey on June 1, 2004 2:37:03 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by MaulingMonkey
Create the header files as seperate files? Err, here''s the kind of thing I do:

--MyClass.h--
#ifndef MYCLASS_H //include guard
#define MYCLASS_H //(prevents multiple decleration warnings)
class MyClass
{
public:
void DoSomething( void );
void DoAnotherThing( void );
};
#endif //ndef MYCLASS_H //end include guard



--MyClass.cpp--
#include "myclass.h"
void MyClass::DoSomething( void )
{
//actual code...
}
void MyClass::DoAnotherThing( void )
{
//foobar
}


Then:

g++ MyClass.cpp main.cpp otherfile.cpp -o program -lstdc++ -lSDL_main -lSDL -lOpenGL32

or the like.

Maybe if you clarify your problem? (edit: read: like, ya know, tell us what errors are popping up? For all we know the compiler is crashing XD)

I''m guessing some of them probably stem from not selecting what libraries you''re linking against? (those -l____ flags).

[edited by - MaulingMonkey on June 1, 2004 2:37:03 PM]


you left out #endif



Sharp Basic - Coming summer 2004!
Sign Up For Sharp Basic Beta Testing!!!

Share this post


Link to post
Share on other sites
quote:
Original post by MaulingMonkey
void DoSomething( void );
void DoAnotherThing( void );
};
#endif //ndef MYCLASS_H //end include guard //<--------------------------------- RIGHT HERE



--MyClass.cpp--
#include "myclass.h"
void MyClass::DoSomething( void )
{
*snip*



quote:
Original post by DerAnged
you left out #endif



No I didn't. The [ code ] tag ate my newlines inserted to seperate the files clearly though. I can understand where you got this mistaken idea.

[edited by - MaulingMonkey on June 1, 2004 2:53:50 PM]

Share this post


Link to post
Share on other sites
Well... the program usually just crashes and the problem is mainly it doesn''t seem to recognize header files for some reason

Future Game Desinger...

Currently studying C++, Oracle, Visual Basic 6.0

Share this post


Link to post
Share on other sites
When you insert an include statement the contents of the header is copy/replaced there conceptually so you can''t compile header files on there own they get included in the code that gets compiled.

If your program is compiled and running then crashes then header files has nothing to do with it you have a bug in your program, why don''t you post your code

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!