![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
|
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 );
};
}
#endifEncryption.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. |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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 |
|
|
|
|
|
#3 |
|
Programmer
|
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. |
|
|
|
|
|
#4 |
|
Expert Programmer
Join Date: Jun 2005
Posts: 852
Rep Power: 4
![]() |
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.
|
|
|
|
|
|
#5 |
|
Newbie
Join Date: Mar 2007
Posts: 24
Rep Power: 0
![]() |
In VC 2005 right click on project's name -> Linker -> Input -> Additional dependencies and select the library.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
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 |