Jump to content
  • Advertisement

Archived

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

imDivineLight

Precompiled Headers, and Static Libs

This topic is 5276 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

Hi! My engine code is growing day by day, it consists of 65 Files, Oh My!, Now i want to use static library which will contain my engine code seperated from game code, so far i have created libraries that contains only *.cpp files precompiled, i have to give libraries for those cpp files with my Library headers, now i don''t want that, i also want to hide my headers. So only user can attach library and use it, he must not see the implementation. Isn''t there any thing that also compile those headers into some sort of file, and we can use that single file to include all headers?? because currently 32 of my files are headers and including them all in a new project or distributing them is a headache. I have heard the term Precompiled headers, but i don''t know exactly what they are and how to use them. I think they will allow me to put all my headers in one file that is easy to embed in new projects. Is there any tutorial using precompiled headers or please can you calrify this subject?? in the lesson examples of drunken hyena, he uses some very good technique to fight this problem. I don''t know how he has included his engine in lesson project, because the workspace shows header files of engine, but when i open them it says, no such file create a new one?, and still those headers are used in lesson code. Kinda invisible, this thing attracts me most any way around this? Educate me!

Share this post


Link to post
Share on other sites
Advertisement
Precompiled headers are something else entirely.

The solution is to divide your header files into two sets: public and private. You code uses both sets, but you distribute only the public header files.

You may have to reorganize your code and perhaps add extra code to decouple the interface from the implementation.


John Bolton
Page 44 Studios
Current project: NHL Faceoff 2005 PS2

Share this post


Link to post
Share on other sites
if i want to hide completely my source code from anyone who want to use my engine, can''t i use static techniques?? Static libraries etc this is my question, i can''t afford to give a single file, so am i candidate for DLLs??

Or there is another static way?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You *must* at least supply the header files, together with your lib or dll in order to keep it usable. There is no way around it.

As John said, separate implementation from interface. There is no harm releasing the interface headers for even the most secret implementation on earth. In fact, it is even encouraged. Clean and well documented interface specs are crucial for developers using a third party API.

Share this post


Link to post
Share on other sites
ok, as far as i and you know, it''s the only solution, i have given it up, and now my *.LIB contains all the headers, and they are also very tightly packed with comments.

But no one dared to answer this question:
How Drunken Hyena used his engine without even giving the implementation?? see his tutorials.

Share this post


Link to post
Share on other sites
quote:
Original post by imDivineLight

in the lesson examples of drunken hyena, he uses some very good technique to fight this problem. I don't know how he has included his engine in lesson project, because the workspace shows header files of engine, but when i open them it says, no such file create a new one?, and still those headers are used in lesson code. Kinda invisible, this thing attracts me most any way around this?




Taken from init_d3d.cpp (part of Drunken Hyena's Direct3D tuts)



//

// init_d3d.cpp - Initializing Direct3D9

//

// Copyright (c) 2003 Drunken Hyena

//

// This program is free software; you can redistribute it and/or modify it

// under the terms of the Drunken Hyena License. If a copy of the license was

// not included with this software, you may get a copy from:

// http://www.drunkenhyena.com/docs/DHLicense.txt

//

#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers

#include <D3DX9.h>
#include "../common/dhWindow.h"
#include "../common/dhD3D.h"
#include "../common/dhUtility.h"

// ....... rest of code follows here



Notice those last three #includes ?
There you see how he includes his headers (part of his common library) into the project.

Edit: tags messed up


[edited by - Direct4D on June 8, 2004 7:42:59 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by Direct4D
Notice those last three #includes ?
There you see how he includes his headers (part of his common library) into the project.

Edit: tags messed up


[edited by - Direct4D on June 8, 2004 7:42:59 AM]


i think you have an older version of his tuts. i have the new one which use his own engine, some kind of wrapper, look here, it includes those headers, but i never see them included in the zip, how is that possible?


#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers

#include <D3DX8.h>
#include <stdio.h>
#include <mmsystem.h>

#include "dhEngine.h"
#include "dhSimpleMesh.h"
#include "dhFPSTimer.h"

Share this post


Link to post
Share on other sites
quote:

it includes those headers, but i never see them included in the zip, how is that possible?


It''s not, unless the headers are actually there and you didn''t notice them. Next time you ask a question about something you might want to try googling it, first:
Googling "what are precompiled headers" gave me this as the first result.

Share this post


Link to post
Share on other sites
quote:
Original post by imDivineLight
...
i think you have an older version of his tuts. i have the new one which use his own engine, some kind of wrapper, look here, it includes those headers, but i never see them included in the zip, how is that possible?
...



What zip do you mean ? A tutorial or the dhEngine ?
I just downloaded dhEngine.zip from his site and it contained all the neccesary headers.

If you don''t have these headers then the tuts won''t even compile.

Like JohnBolton allready said: (though he said it with less words and probably alot more clear)

Just include the headers that contain the class definitions and function prototypes with your libs.
And the headers that contain classes and or function prototypes that are for "internal" use only, can be kept private. Don''t destribute those with the lib.

Suppose you have a function that uses your uber secret algorithm.
Then what harm would it cause to distribute it''s prototype in a header ?
in ubersecret.h:
int PerformUberSecretAlgorithm(int a, int b);

The actual implementation is hidden in the cpp file. Which is compiled and thus not distributed with your lib.
in ubersecret.cpp

int PerformUberSecretAlgorithm(int a, int b){
// secret algorithm goes here

}

Share this post


Link to post
Share on other sites
Thanks for the info, and yah in the tutorial, they are not given, and i never recompiled it, so i think that was majik, but when i recompiled it it says fatal error no dhEngine.h, so i have to download the dhEngine also

Sorry for misunderstanding, ok so my lesson is that there''s no way to hide those headers because there''s no reason for them alright? but what about inline functions they are in those headers?

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!