Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 12th, 2007, 8:04 PM   #1
Ben.Dougall
Programmer
 
Ben.Dougall's Avatar
 
Join Date: Jul 2007
Location: London, Ontario, Canada
Posts: 34
Rep Power: 0 Ben.Dougall is on a distinguished road
Send a message via MSN to Ben.Dougall
Issues with creating Library

I'm currently making a library for a bunch of general tasks. I currently have about 6 classes to make into a library. Up until now, i have been going strictly .hpp files, with all the content in a .hpp instead of .hpp/.cpp . Instead of killing myself over switching everything and not having it work, i made a simple project ( static library ).

So i have two files:
Encryption.hpp
#ifndef GUARD_Encryption_hpp
#define GUARD_Encryption_hpp

#include <string>

namespace BenLib
{
	class Encryption
	{
	private:
		Encryption(void);
	public:	
		~Encryption(void);
		static void Encrypt( std::string &text );
	};

}
#endif

Encryption.cpp
#include "Encryption.hpp"

namespace BenLib
{
	void Encryption::Encrypt( std::string &text )  
	{
		for ( unsigned i = 0; i < text.size(); ++i )
			text[i] = text[i] - 5;
	}
}

So it comes out with a .lib file ( so i make a inc folder for the .hpp, and a lib file for the .lib, add it to the VC++ Directories ( includes and libraries sections ).

When i test it, i get a linker error for BenLib::Encryption::Encrypt. It recognizes the fact Encryption.hpp exists, but it doesn't link to Encryption.lib. I've searched online for this, with no prevail.

Any help would be absolutly amazing, and very much appriciated... I'm about to go crazy trying to figure it out.
__________________
My site :: http://www.freewebtown.com/dougalbe
I'll try to be nicer, if you try being smarter.
Ben.Dougall is offline   Reply With Quote
Old Jul 12th, 2007, 9:08 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Header files should be declarations, not working code. It's not easy to tell from your post if you actually figured this out and handled it. I would recommend that you learn precisely what a build process does.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jul 12th, 2007, 9:44 PM   #3
Ben.Dougall
Programmer
 
Ben.Dougall's Avatar
 
Join Date: Jul 2007
Location: London, Ontario, Canada
Posts: 34
Rep Power: 0 Ben.Dougall is on a distinguished road
Send a message via MSN to Ben.Dougall
I'm starting to port everything into seperate files ( aka headers = class declarations/method prototypes, cpp's holding method bodies )

Now its the issue of getting a linker error when i try to make this a library through VC++ directories.
__________________
My site :: http://www.freewebtown.com/dougalbe
I'll try to be nicer, if you try being smarter.
Ben.Dougall is offline   Reply With Quote
Old Jul 13th, 2007, 6:48 AM   #4
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 852
Rep Power: 4 The Dark is on a distinguished road
You have to add the library to your project, or add the library name to the project settings under "Linker - Input" (I think). Just pointing to the library directory in the directory settings isn't enough.
The Dark is online now   Reply With Quote
Old Jul 19th, 2007, 4:24 PM   #5
l2u
Newbie
 
Join Date: Mar 2007
Posts: 24
Rep Power: 0 l2u is on a distinguished road
In VC 2005 right click on project's name -> Linker -> Input -> Additional dependencies and select the library.
l2u is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Discussion: How to implement the 'glue' between app and a library? Eoin C++ 10 Sep 28th, 2006 8:14 AM
Library problem creating Direct3d Object Kilo C++ 9 May 30th, 2006 8:48 AM
3d Graphics Library Creating Malekos Visual Basic 39 May 13th, 2006 9:13 PM
what is the difference between an API and a library? linuxpimp20 Other Programming Languages 6 Aug 27th, 2005 7:25 AM
Code library (in working progress) Cerulean Python 4 Jul 7th, 2005 8:58 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:45 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC