944,173 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1053
  • C++ RSS
Feb 26th, 2007
0

Libraries

Expand Post »
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
Attached Files
File Type: cpp prog.cpp (2.5 KB, 6 views)
File Type: cpp proglib.cpp (2.2 KB, 5 views)
File Type: h proglib.h (305 Bytes, 5 views)
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
trunks1212 is offline Offline
5 posts
since Feb 2007
Feb 26th, 2007
0

Re: Libraries

Click to Expand / Collapse  Quote originally posted by trunks1212 ...
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
Reputation Points: 11
Solved Threads: 13
Junior Poster
Lazaro Claiborn is offline Offline
171 posts
since Jan 2007
Feb 26th, 2007
0

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.
Reputation Points: 237
Solved Threads: 117
Practically a Posting Shark
Clinton Portis is offline Offline
822 posts
since Oct 2005
Feb 26th, 2007
0

Re: Libraries

I'm using Dev CPP
Reputation Points: 10
Solved Threads: 0
Newbie Poster
trunks1212 is offline Offline
5 posts
since Feb 2007
Feb 26th, 2007
0

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.
Team Colleague
Reputation Points: 2240
Solved Threads: 338
Vampirical Lurker
John A is offline Offline
5,055 posts
since Apr 2006
Feb 26th, 2007
0

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
trunks1212 is offline Offline
5 posts
since Feb 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: plzzzzzzzzzzz help me............
Next Thread in C++ Forum Timeline: Encryptor





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC