Hi all.

And Thank you Dear Geoff!

I compiled the code you introduced me that was as following:

#include "secblock.h"
#include "files.h"
#include "sha.h"
#include "hex.h"

#include <iostream>

using namespace std;
using namespace CryptoPP;
int main(int argc, char** argv)
{
    try {
        if(argc < 2){
            cerr << "Usage: " << argv[0] << " file" << endl;
            return 1;
        }
        SHA1 sha;
        SecByteBlock outbuf(sha.DigestSize());
        FileSource hasher(argv[1], true, new HashFilter(sha,new ArraySink

(outbuf,outbuf.size())));
        cout << "SHA1(" << argv[1] << "): ";
        HexEncoder(new FileSink(cout)).Put(outbuf,outbuf.size());
        cout << endl;
    } catch(std::exception &e) {
        cerr << "Caught an exception: " << e.what() << endl;
        return 1;
    }
    return 0;
}



But I got 77 link errors as the following:

------ Build started: Project: Hash-SHA1, Configuration: Debug Win32
------
Compiling...
1.cpp
Linking...
1.obj : error LNK2019: unresolved external symbol "public: virtual
void __thiscall CryptoPP::Filter::Detach(class
CryptoPP::BufferedTransformation *)" (?
det...@filter@CryptoPP@@uaexpavbufferedtransformat...@2@@Z) referenced
in function "public: __thiscall CryptoPP::HashFilter::HashFilter(class
CryptoPP::HashTransformation &,class
CryptoPP::BufferedTransformation *,bool,int)" (??
0hashfil...@cryptopp@@q...@aavhashtransformation@1...@pavbufferedtransformation@1...@_nh@Z)

1.obj : error LNK2001: unresolved external symbol "public: virtual
unsigned int __thiscall CryptoPP::HashFilter::Put2(unsigned char const
*,unsigned int,int,bool)" (?p...@hashfilter@CryptoPP@@uaeipbei...@z)

1.obj : error LNK2001: unresolved external symbol "public: virtual
void __thiscall CryptoPP::HashFilter::IsolatedInitialize(class
CryptoPP::NameValuePairs const &)" (?
isolatedinitial...@hashfilter@CryptoPP@@uaexabvnamevaluepa...@2@@Z)

1.obj : error LNK2001: unresolved external symbol "public: virtual
void __thiscall CryptoPP::Filter::Initialize(class
CryptoPP::NameValuePairs const &,int)" (?
initial...@filter@CryptoPP@@uaexabvnamevaluepa...@2@h...@z)

1.obj : error LNK2001: unresolved external symbol "public: virtual
bool __thiscall CryptoPP::Filter::Flush(bool,int,bool)" (?
fl...@filter@CryptoPP@@uae_n_...@z)

1.obj : error LNK2001: unresolved external symbol "public: virtual
bool __thiscall CryptoPP::Filter::MessageSeriesEnd(int,bool)" (?
messageseries...@filter@CryptoPP@@uae_n...@z)

1.obj : error LNK2001: unresolved external symbol "public: virtual
unsigned __int64 __thiscall
CryptoPP::BufferedTransformation::MaxRetrievable(void)const
maxretrieva...@bufferedtransformation@CryptoPP@@UBE_KXZ)
.
.
.

D:\Hash-SHA1.exe : fatal error LNK1120: 76 unresolved externals

Hash-SHA1 - 77 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
==========


Then I changed the above code to a simpler form as below:

#include "secblock.h"
#include "filters.h"
#include "sha.h"
#include "hex.h"

#include <iostream>
using namespace std;
using namespace CryptoPP;

int main()
{
        SHA1 sha;
        string sData ="Test Message";

        byte abDigest[SHA1::DIGESTSIZE];

        StringSource(sData, true,
         new HashFilter(sha,
         new ArraySink(abDigest, sizeof(abDigest))));

        HexEncoder(new ArraySink(abDigest, sizeof(abDigest)));

        for(int i=0;i<sizeof(abDigest);i++)
        cout << "SHA1 value" << abDigest[i]<<" | ";
        cout << endl;

    return 0;
}


And after compiling it,I got 72 link errors as below again:

------ Build started: Project: Hash-SHA1, Configuration: Debug Win32
------
Compiling...
1.cpp
Linking...
1.obj : error LNK2019: unresolved external symbol "public: virtual
void __thiscall CryptoPP::Filter::Detach(class
CryptoPP::BufferedTransformation *)" (?
det...@filter@CryptoPP@@uaexpavbufferedtransformat...@2@@Z) referenced
in function "public: __thiscall CryptoPP::HashFilter::HashFilter(class
CryptoPP::HashTransformation &,class CryptoPP::BufferedTransformation
*,bool,int)" (??
0hashfil...@cryptopp@@q...@aavhashtransformation@1...@pavbufferedtransformation@1...@_nh@Z)

1.obj : error LNK2001: unresolved external symbol "public: virtual
unsigned int __thiscall CryptoPP::HashFilter::Put2(unsigned char const
*,unsigned int,int,bool)" (?p...@hashfilter@CryptoPP@@uaeipbei...@z)

1.obj : error LNK2001: unresolved external symbol "public: virtual
void __thiscall CryptoPP::HashFilter::IsolatedInitialize(class
CryptoPP::NameValuePairs const &)" (?
isolatedinitial...@hashfilter@CryptoPP@@uaexabvnamevaluepa...@2@@Z)

1.obj : error LNK2001: unresolved external symbol "public: virtual
void __thiscall CryptoPP::Filter::Initialize(class
CryptoPP::NameValuePairs const &,int)" (?
initial...@filter@CryptoPP@@uaexabvnamevaluepa...@2@h...@z)

1.obj : error LNK2001: unresolved external symbol "public: virtual
bool __thiscall CryptoPP::Filter::Flush(bool,int,bool)" (?
fl...@filter@CryptoPP@@uae_n_...@z)

1.obj : error LNK2001: unresolved external symbol "public: virtual
bool __thiscall CryptoPP::Filter::MessageSeriesEnd(int,bool)" (?
messageseries...@filter@CryptoPP@@uae_n...@z)

1.obj : error LNK2001: unresolved external symbol "public: virtual
unsigned __int64 __thiscall
CryptoPP::BufferedTransformation::MaxRetrievable(void)const " (?
maxretrieva...@bufferedtransformation@CryptoPP@@UBE_KXZ)

1.obj : error LNK2001: unresolved external symbol "public: virtual
bool __thiscall CryptoPP::BufferedTransformation::AnyRetrievable(void)
const " (?
anyretrieva...@bufferedtransformation@CryptoPP@@UBE_NXZ)
.
.
.

D:\Hash-SHA1.exe : fatal error LNK1120: 71 unresolved externals

Hash-SHA1 - 72 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
==========


I have read the below article at "Codeproject.com" site:
"attachment:/1/CryptoPPIntegration.htm"

And there are details about "2019" and "2001" link errors in it such
below:


Link Error 2019 When Using the FIPS DLL

This error is due to the FIPS DLL only exporting certified algorithms
such as AES. Wei offers two solutions to the issue. First, you can
statically link against the library.
Second, you must use the DLL version of the library (not the FIPS
DLL). Then, to export the missing classes of interest, add the
CRYPTOPP_DLL macro to the class declaration. Then
rebuild the DLL-Import project.

Link Error 2001

The Crypto++ output libraries are located at Win32\output\debug
\cryptlib.lib and Win32 \output\release\cryptlib.lib. The DLL and its
export library are in Win32\dll_output. Note the "dll_" in the path
name. Verify that you are using the correct paths.



I have added the "CryptoPP" library to my visual studio environment
with the below instructions respectively and have built some sample
codes with these instructions succesfully:

1.Rename the library file from cryptlib.lib to cryptlibd.lib (notice
the addition of the "d" for Debug).

2.Move the Debug Library to the location of the Header and Source
Files. Also, move (without renaming) the Release version to the same
folder.

3-Add the location of the Header Files, Source Files, and Libraries to
the VC++ Environment. Select Tools | Options, Directories Tab.

4- Add the location of the Header Files, Source Files, and Libraries
to the VC++ Project.


But I don't know what is this problem from?


BTW,I already had compiled one sample code of hashig data with some
algorithms including SHA1 and had gotten the same link errors!

Really,why do I face these link errors?

Help me please!

Best Regards.
Gary.

On Feb 23, 7:43 am, Geoff Beier <[email protected]> wrote:
> On Sun, Feb 22, 2009 at 16:31, Geoff Beier <[email protected]> wrote:
>
> >http://cryptopp.pastebin.com/f4a986357
>
> Sorry to reply to my own post, but I just noticed that someone had
> posted a question as an edit to the code in the pastebin, and I wanted
> to redirect the follow-up discussion here, since most of us won't
> notice things added to the pastebin unless they're called out on this
> list :-)
>
> A user with the handle Dio asked:
> 20      +       @What is SecByteBlock means?@
> 21      +       @SecByteBlock outbuf(sha.DigestSize());@
>
> SecByteBlock is defined in the cryptopp header secblock.h. Read there
> for full details of what it's good for. Here, I'm just using it as a
> convenient smart pointer to a byte array. Others may want to correct
> me, but offhand I'd say that every occasion I can think of where I'd
> want to use a byte array with a crypto++ interface, it's safer/more
> convenient to use a SecByteBlock.
>
> Geoff
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---

Reply via email to