DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C++ (http://www.daniweb.com/forums/forum8.html)
-   -   Libraries (http://www.daniweb.com/forums/thread71114.html)

trunks1212 Feb 26th, 2007 6:54 pm
Libraries
 
3 Attachment(s)
I'm trying to compile my program using library functions I created. I can't figure out how to get it to work. I'm going to attach my files so if someone could help me that would be great

Lazaro Claiborn Feb 26th, 2007 7:02 pm
Re: Libraries
 
Quote:

Originally Posted by trunks1212 (Post 320908)
I'm trying to compile my program using library functions I created. I can't figure out how to get it to work. I'm going to attach my files so if someone could help me that would be great

First thing I'd suggest is to use condition prepressor directives to prevent header inclusion. In your header file "proglib.h" enclose your code like this:

#ifndef PROGLIB_H
#define PROGLIB_H
....function prototypes and/or constants and/or etc...
#endif

Next make sure your header file and its corresponding .cpp file are in the same directory, unless you've got your compiler configured to search certainly and not by default. Actually, what compiler you using? Is it command line or IDE GUI? Let me know.

Good luck, LamaBot

Clinton Portis Feb 26th, 2007 7:05 pm
Re: Libraries
 
what compiler are ye' using?

for most IDE's like Dev CPP and MSVC++ 6.0, there is an option to, "add to project".. make sure the you are adding all 3 files to your project, then try to compile.

If you are using a command line compiler like borland, you will have to learn the codes for linking files together.. which I used to remember but I don't anymore.

trunks1212 Feb 26th, 2007 7:16 pm
Re: Libraries
 
I'm using Dev CPP

John A Feb 26th, 2007 7:50 pm
Re: Libraries
 
>I can't figure out how to get it to work.
So then tell us what doesn't work, so we don't have to guess.

trunks1212 Feb 26th, 2007 7:59 pm
Re: Libraries
 
Ok sorry I figured it out. I had to put #include <fstream> and using namespace std; in my header file and now it works fine. And I did what you said about putting all the files in a project. So sorry again and thank you for all your help.


All times are GMT -4. The time now is 10:00 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC