Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C++ (http://www.programmingforums.org/forum15.html)
-   -   Issues with creating Library (http://www.programmingforums.org/showthread.php?t=13539)

Ben.Dougall Jul 12th, 2007 9:04 PM

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.

DaWei Jul 12th, 2007 10:08 PM

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.

Ben.Dougall Jul 12th, 2007 10:44 PM

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.

The Dark Jul 13th, 2007 7:48 AM

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.

l2u Jul 19th, 2007 5:24 PM

In VC 2005 right click on project's name -> Linker -> Input -> Additional dependencies and select the library.


All times are GMT -5. The time now is 2:28 AM.

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