some help needed for beginner (Crypto++ 5.5.2 - Ubuntu Feisty - Eclipse - GCC4)

304 views
Skip to first unread message

Naja Melan

unread,
Feb 20, 2008, 1:01:59 PM2/20/08
to cryptop...@googlegroups.com
Hi,

Im trying to use crypto++, but Im a complete beginner at linux, C++ and eclipse,  and its not really working out... I want to write a hash calculator to get the hang of C++ and Qt and wanted to use the  crypto++ library for the hash functions. I have gotten this far:

downloaded crypto from sourceforge, then unzip -a, make all install. All without errors :)
 (I tried before compiling it in eclipse, and that gave about 300 errors, i don't understand why...)

Now i would like to use it for a managed make C++ project in Eclipse (other small C++ apps compile, build and run without problem). I have the right dir in my include path (/usr/include/cryptopp/) and made a little test source to see what happens:

#include "sha.h"
using namespace CryptoPP;

int main()
{
   SHA hash;
   return 0;
}


The marked line gives the following errors:
  1. /usr/include/cryptopp/cryptlib.h undefined reference to `vtable for CryptoPP::HashTransformation'
  2. /usr/include/cryptopp/iterhash.h undefined reference to `CryptoPP::IteratedHashBase<unsigned int, CryptoPP::HashTransformation>::IteratedHashBase()'
  3. /usr/include/cryptopp/iterhash.h undefined reference to `CryptoPP::SHA1::InitState(unsigned int*)'
  4. /usr/include/cryptopp/iterhash.h undefined reference to `CryptoPP::SHA1::Transform(unsigned int*, unsigned int const*)'
  5. /usr/include/cryptopp/iterhash.h undefined reference to `vtable for CryptoPP::IteratedHashBase<unsigned int, CryptoPP::HashTransformation>'
So, the obvious question,... What am i doing wrong...

Also i have an other question. As the make install also generated some sort of shared library, i wondered, if i write an app and compile it, will it be stand alone, or will it need this library to be shipped with it... If so is it possible to have it completely standalone, and is that usefull... I just havent got a clue about all this...

Thank you very much in advance for any help, hints and explanations

greets
naja

Eugen

unread,
Feb 20, 2008, 1:20:10 PM2/20/08
to Crypto++ Users
sorry Crypto++ guys, but after I spend 2 hours by trying to figure out
how everything works ( documentation sucks, sorry ) and after this
when I got the linker error, I sad that's enough for me and started to
look around for another crypt library.
After a few google I found the Botan library http://botan.randombit.net/
I spent 5 mins to read its docs, then solved my problem in another 10
mins.

so, what I want to say to you Naja, you may want to look at Botan
library too.

Have fun.

On Feb 20, 11:01 am, "Naja Melan" <najame...@gmail.com> wrote:
> Hi,
>
> Im trying to use crypto++, but Im a complete beginner at linux, C++ and
> eclipse, and its not really working out... I want to write a hash
> calculator to get the hang of C++ and Qt and wanted to use the crypto++
> library for the hash functions. I have gotten this far:
>
> downloaded crypto from sourceforge, then unzip -a, make all install. All
> without errors :)
> (I tried before compiling it in eclipse, and that gave about 300 errors, i
> don't understand why...)
>
> Now i would like to use it for a managed make C++ project in Eclipse (other
> small C++ apps compile, build and run without problem). I have the right dir
> in my include path (/usr/include/cryptopp/)* *and made a little test source
> to see what happens:
>
> #include "sha.h"
> using namespace CryptoPP;
>
> int main()
> {
> * SHA hash;*
> return 0;
>
> }
>
> The marked line gives the following errors:
>
> 1. */usr/include/cryptopp/cryptlib.h* undefined reference to `vtable
> for CryptoPP::HashTransformation'
> 2. */usr/include/cryptopp/iterhash.h* undefined reference to
> `CryptoPP::IteratedHashBase<unsigned int,
> CryptoPP::HashTransformation>::IteratedHashBase()'
> 3. */usr/include/cryptopp/iterhash.h* undefined reference to
> `CryptoPP::SHA1::InitState(unsigned int*)'
> 4. */usr/include/cryptopp/iterhash.h* undefined reference to
> `CryptoPP::SHA1::Transform(unsigned int*, unsigned int const*)'
> 5. */usr/include/cryptopp/iterhash.h* undefined reference to `vtable

naja

unread,
Feb 20, 2008, 1:26:17 PM2/20/08
to Crypto++ Users
I will have a look, but i hear many good things about Crypto++ and the
OO code looks really good as well at first sight...

Naja Melan

unread,
Feb 21, 2008, 2:02:34 PM2/21/08
to Crypto++ Users
This looks like it (from the C++ faq):

[23.10] What does it mean that the "virtual table" is an unresolved external?

If you get a link error of the form "Error: Unresolved or undefined symbols detected: virtual table for class Fred," you probably have an undefined virtual member function in class Fred.

The compiler typically creates a magical data structure called the "virtual table" for classes that have virtual functions (this is how it handles dynamic binding). Normally you don't have to know about it at all. But if you forget to define a virtual function for class Fred, you will sometimes get this linker error.

Here's the nitty gritty: Many compilers put this magical "virtual table" in the compilation unit that defines the first non-inline virtual function in the class. Thus if the first non-inline virtual function in Fred is wilma(), the compiler will put Fred's virtual table in the same compilation unit where it sees Fred::wilma(). Unfortunately if you accidentally forget to define Fred::wilma(), rather than getting a Fred::wilma() is undefined, you may get a "Fred's virtual table is undefined". Sad but true.




Now looking at HashTransformation, the only non inline non pure virtual method is: TruncatedVerify. This one is implemented in cryptlib.cpp. I thought i read somewhere that you had to define them in the header file, and not in the cpp, so i tried to move it to the header file, but then i get more errors because this function uses types that are not yet declared, porting the "#includes" to cryptlib.h gave tons of errors, so as it stands knowing nothing of this library, and only bits and bobs of C++, it looks like i have little chance to solve this myself...


Wei Dai

unread,
Feb 22, 2008, 1:08:05 AM2/22/08
to Naja Melan, cryptop...@googlegroups.com
What this looks like is that you haven't told the compiler/linker to link
your test program with the Crypto++ library (the libcryptopp.a file that got
compiled and installed during "make all install"). I'm not familiar with
Eclipse so I don't know how you would do it in that environment, but I
suggest you look into that.

--------------------------------------------------
From: "Naja Melan" <naja...@gmail.com>
Sent: Wednesday, February 20, 2008 10:01 AM
To: <cryptop...@googlegroups.com>
Subject: some help needed for beginner (Crypto++ 5.5.2 - Ubuntu Feisty -
Eclipse - GCC4)

> Hi,
>
> Im trying to use crypto++, but Im a complete beginner at linux, C++ and
> eclipse, and its not really working out... I want to write a hash
> calculator to get the hang of C++ and Qt and wanted to use the crypto++
> library for the hash functions. I have gotten this far:
>
> downloaded crypto from sourceforge, then unzip -a, make all install. All
> without errors :)
> (I tried before compiling it in eclipse, and that gave about 300 errors, i
> don't understand why...)
>
> Now i would like to use it for a managed make C++ project in Eclipse
> (other
> small C++ apps compile, build and run without problem). I have the right
> dir

> in my include path (/usr/include/cryptopp/)* *and made a little test

> source
> to see what happens:
>
> #include "sha.h"
> using namespace CryptoPP;
>
> int main()
> {

> * SHA hash;*


> return 0;
> }
>
>
> The marked line gives the following errors:
>

> 1. */usr/include/cryptopp/cryptlib.h* undefined reference to `vtable
> for CryptoPP::HashTransformation'
> 2. */usr/include/cryptopp/iterhash.h* undefined reference to


> `CryptoPP::IteratedHashBase<unsigned int,
> CryptoPP::HashTransformation>::IteratedHashBase()'

> 3. */usr/include/cryptopp/iterhash.h* undefined reference to
> `CryptoPP::SHA1::InitState(unsigned int*)'
> 4. */usr/include/cryptopp/iterhash.h* undefined reference to


> `CryptoPP::SHA1::Transform(unsigned int*, unsigned int const*)'

> 5. */usr/include/cryptopp/iterhash.h* undefined reference to `vtable

Reply all
Reply to author
Forward
0 new messages