Trying to get started with Crypto++ getting linking errors

View: New views
11 Messages — Rating Filter:   Alert me  

Trying to get started with Crypto++ getting linking errors

by inderpaul :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I am trying to compile a simple program source code included below
which taken from another post just recently.  Working with Visual C++
6.0 on Windows 2000/XP.

http://groups.google.com/group/cryptopp-users/browse_thread/thread/e26965549c4dac33

I added all of the cpp files associated with the required .h files but
still am getting a few linking errors posted below also. Any advice or
suggestions would be greatly appreciated.

--------------------Source Code test1 --------------------

// test1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <stdlib.h>
#include "cryptlib.h"
#include "default.h"
#include "hex.h"
#include "modes.h"
#include "aes.h"

using namespace CryptoPP;
using namespace std;

char *EncryptString(const char *instr, const char *passPhrase) ;

// encode a string using passPhrase and encode it in hex
int main(int argc, char* argv[])
{
  //cout << crypt("firstpas", "as"); << "\n";
  cout << EncryptString("test string", "passwd") << "\n";
  return 0;

}

// returns the ciphertext, which should be deleted by caller
char *EncryptString(const char *instr, const char *passPhrase)
{
        unsigned int len=strlen(instr);
        char* outstr;


        DefaultEncryptor encryptor(passPhrase, new HexEncoder);
        //DefaultEncryptorWithMAC encryptor(passPhrase, new HexEncoder);
        //encryptor.Put((byte *)instr, len);
        //encryptor.MessageEnd();

        //unsigned int outputLength = encryptor.MaxRetrievable();
        //outstr = new char[outputLength+1];
        //encryptor.Get((byte *)outstr, outputLength);
        //outstr[outputLength] = 0;
        return outstr;
}

--------------------Configuration: test1 - Win32
Debug--------------------
Compiling...
randpool.cpp
d:\devs3\cryptography\cryptopp560\randpool.cpp(42) : error C2440:
'initializing' : cannot convert from 'int' to 'struct
CryptoPP::CompileAssert<1>'
        No constructor could take the source type, or constructor
overload resolution was ambiguous
d:\devs3\cryptography\cryptopp560\randpool.cpp(46) : error C2370:
'cryptopp_assert_' : redefinition; different storage class
        d:\devs3\cryptography\cryptopp560\randpool.cpp(42) : see
declaration of 'cryptopp_assert_'
d:\devs3\cryptography\cryptopp560\randpool.cpp(46) : error C2440:
'initializing' : cannot convert from 'int' to 'struct
CryptoPP::CompileAssert<1>'
        No constructor could take the source type, or constructor
overload resolution was ambiguous
Error executing cl.exe.

test1.exe - 3 error(s), 0 warning(s)
----------------------------------------------------------------------------------------------------
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscribe@....
More information about Crypto++ and this group is available at http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---


Re: Trying to get started with Crypto++ getting linking errors

by Jeffrey Walton-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi inderpaul,

I've encountered this with VC 6.0 when building a custom library
rather than using the stock Crypto++ library. Comment out the two
COMPILE_TIME_ASSERTs in RandomPool.

Jeff

On 8/1/09, inderpaul <inderpaul_s@...> wrote:

>
> I am trying to compile a simple program source code included below
> which taken from another post just recently.  Working with Visual C++
> 6.0 on Windows 2000/XP.
>
> http://groups.google.com/group/cryptopp-users/browse_thread/thread/e26965549c4dac33
>
> I added all of the cpp files associated with the required .h files but
> still am getting a few linking errors posted below also. Any advice or
> suggestions would be greatly appreciated.
>
> --------------------Source Code test1 --------------------
>
> // test1.cpp : Defines the entry point for the console application.
> //
>
> #include "stdafx.h"
> #include <iostream>
> #include <stdlib.h>
> #include "cryptlib.h"
> #include "default.h"
> #include "hex.h"
> #include "modes.h"
> #include "aes.h"
>
> using namespace CryptoPP;
> using namespace std;
>
> char *EncryptString(const char *instr, const char *passPhrase) ;
>
> // encode a string using passPhrase and encode it in hex
> int main(int argc, char* argv[])
> {
>  //cout << crypt("firstpas", "as"); << "\n";
>  cout << EncryptString("test string", "passwd") << "\n";
>  return 0;
>
> }
>
> // returns the ciphertext, which should be deleted by caller
> char *EncryptString(const char *instr, const char *passPhrase)
> {
>        unsigned int len=strlen(instr);
>        char* outstr;
>
>
>        DefaultEncryptor encryptor(passPhrase, new HexEncoder);
>        //DefaultEncryptorWithMAC encryptor(passPhrase, new HexEncoder);
>        //encryptor.Put((byte *)instr, len);
>        //encryptor.MessageEnd();
>
>        //unsigned int outputLength = encryptor.MaxRetrievable();
>        //outstr = new char[outputLength+1];
>        //encryptor.Get((byte *)outstr, outputLength);
>        //outstr[outputLength] = 0;
>        return outstr;
> }
>
> --------------------Configuration: test1 - Win32
> Debug--------------------
> Compiling...
> randpool.cpp
> d:\devs3\cryptography\cryptopp560\randpool.cpp(42) : error C2440:
> 'initializing' : cannot convert from 'int' to 'struct
> CryptoPP::CompileAssert<1>'
>        No constructor could take the source type, or constructor
> overload resolution was ambiguous
> d:\devs3\cryptography\cryptopp560\randpool.cpp(46) : error C2370:
> 'cryptopp_assert_' : redefinition; different storage class
>        d:\devs3\cryptography\cryptopp560\randpool.cpp(42) : see
> declaration of 'cryptopp_assert_'
> d:\devs3\cryptography\cryptopp560\randpool.cpp(46) : error C2440:
> 'initializing' : cannot convert from 'int' to 'struct
> CryptoPP::CompileAssert<1>'
>        No constructor could take the source type, or constructor
> overload resolution was ambiguous
> Error executing cl.exe.
>
> test1.exe - 3 error(s), 0 warning(s)
> ----------------------------------------------------------------------------------------------------

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscribe@....
More information about Crypto++ and this group is available at http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---


Re: Trying to get started with Crypto++ getting linking errors

by inderpaul :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Aug 1, 5:13 pm, Jeffrey Walton <noloa...@...> wrote:
> Hi inderpaul,
>
> I've encountered this with VC 6.0 when building a custom library
> rather than using the stock Crypto++ library. Comment out the two
> COMPILE_TIME_ASSERTs in RandomPool.
>
> Jeff
>

Thanks Jeff. I'll give that a try.

I just had another question to ask. Would compiling a custom libary
build a smaller footprint then compiling the stock version ? I can
remember opening the VC++ 6.0 project files from the Crypto++ 5.6.0
download and the result after compiling and building was a 12MB dll
file. Does this sound right ? Most of us likely will ever need such a
file size or am I incorrect.

Thanks again

Inderpaul
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscribe@....
More information about Crypto++ and this group is available at http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---


Re: Trying to get started with Crypto++ getting linking errors

by inderpaul :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


One last update I've run into some more linking errors so its back to
square one. I'd thought perhaps I'd look again at the project provided
by the Crypto++ download to see if I can make some progress. Hopefully
its the right direction to go. Thanks again to Jeff for the help.

Best Regards

Inderpaul
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscribe@....
More information about Crypto++ and this group is available at http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---


Re: Trying to get started with Crypto++ getting linking errors

by inderpaul :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Aug 3, 6:41 pm, inderpaul <inderpau...@...> wrote:
> One last update I've run into some more linking errors so its back to
> square one. I'd thought perhaps I'd look again at the project provided
> by the Crypto++ download to see if I can make some progress. Hopefully
> its the right direction to go. Thanks again to Jeff for the help.
>
> Best Regards
>
> Inderpaul

Thanks to help everyone including Jeff and one special thanks goes out
to the project samples provided by Wei Dai as I have managed to get
something working with the two functions EncryptString and
DecryptString.

Best Regards

inderpaul
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscribe@....
More information about Crypto++ and this group is available at http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---


Re: Trying to get started with Crypto++ getting linking errors

by inderpaul :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hello all.

I was hoping that there would not be any objections if I were to ask
another question.

What I would like to do is to create an application which makes use of
only two Crypto++ API namely EncryptString and DecryptString functions
only. I would prefer not to statically link the cyrptlib or make use
of the exported functions of the cyptpdll dll as an extension to my
application. How can I merely hard code these two functions and their
implementations directly into my application without having the over
head of using either of the two above alternatives. Is this possible
and if yes how do I do this ? Any suggestions or ideas would be
greatly appreciated.

Thanks again.

inderpaul_s
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscribe@....
More information about Crypto++ and this group is available at http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---


Re: Trying to get started with Crypto++ getting linking errors

by inderpaul :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hello all again.

I'm running into one single error regarding heap memory. The exact
description of the error is pasted below. According to Microsoft its
either too much memory has been allocated for the heap or not enough.
I am not sure on how to fix this one even I did try a couple of things
but to no avail.

c:\program files\microsoft visual studio\vc98\include\xstring(78) :
fatal error C1076: compiler limit : internal heap limit reached; use /
Zm to specify a higher limit
Error executing cl.exe.

Here is the link to the Microsoft page if it helps anyone.
http://msdn.microsoft.com/en-us/library/bdscwf1c.aspx

Best Regards
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscribe@....
More information about Crypto++ and this group is available at http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---


Re: Trying to get started with Crypto++ getting linking errors

by inderpaul :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Aug 9, 5:10 pm, inderpaul <inderpau...@...> wrote:

> Hello all again.
>
> I'm running into one single error regarding heap memory. The exact
> description of the error is pasted below. According to Microsoft its
> either too much memory has been allocated for the heap or not enough.
> I am not sure on how to fix this one even I did try a couple of things
> but to no avail.
>
> c:\program files\microsoft visual studio\vc98\include\xstring(78) :
> fatal error C1076: compiler limit : internal heap limit reached; use /
> Zm to specify a higher limit
> Error executing cl.exe.
>
> Here is the link to the Microsoft page if it helps anyone.http://msdn.microsoft.com/en-us/library/bdscwf1c.aspx
>
> Best Regards

I believe the included cryptest project was using the cryplib as a
dependency therefore I should be able to create my own test
application using the same type of setup. I was also able  to get
around the above error by using the following switch parameter (/
Zm200) but I am still getting the following two (2) errors:

--------------------Configuration: test1 - Win32
Release--------------------
Linking...
libcpmt.lib(xlock.obj) : error LNK2005: "public: __thiscall
std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined
in libcp.lib(locale.obj)
LINK : warning LNK4098: defaultlib "LIBCMT" conflicts with use of
other libs; use /NODEFAULTLIB:library
Release/test1.exe : fatal error LNK1169: one or more multiply defined
symbols found
Error executing link.exe.

test1.exe - 2 error(s), 1 warning(s)
--------------------Configuration: test1 - Win32
Release--------------------

Any comments or suggestions would be greatly appreciated.

inderpaul
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscribe@....
More information about Crypto++ and this group is available at http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---


Re: Trying to get started with Crypto++ getting linking errors

by Jeffrey Walton-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi inderpaul,

> LINK : warning LNK4098: defaultlib "LIBCMT" conflicts with use of
> other libs; use /NODEFAULTLIB:library
VC 6.0 uses single threaded libraries by default. Crypto++ uses
multithreaded. Also keep an eye on Crypto++ use of static linking to
the C++ runtime versus your project's linkage.

Jeff

On 8/10/09, inderpaul <inderpaul_s@...> wrote:

>
> On Aug 9, 5:10 pm, inderpaul <inderpau...@...> wrote:
> > Hello all again.
> >
> > I'm running into one single error regarding heap memory. The exact
> > description of the error is pasted below. According to Microsoft its
> > either too much memory has been allocated for the heap or not enough.
> > I am not sure on how to fix this one even I did try a couple of things
> > but to no avail.
> >
> > c:\program files\microsoft visual studio\vc98\include\xstring(78) :
> > fatal error C1076: compiler limit : internal heap limit reached; use /
> > Zm to specify a higher limit
> > Error executing cl.exe.
> >
> > Here is the link to the Microsoft page if it helps anyone.http://msdn.microsoft.com/en-us/library/bdscwf1c.aspx
> >
> > Best Regards
>
> I believe the included cryptest project was using the cryplib as a
> dependency therefore I should be able to create my own test
> application using the same type of setup. I was also able  to get
> around the above error by using the following switch parameter (/
> Zm200) but I am still getting the following two (2) errors:
>
> --------------------Configuration: test1 - Win32
> Release--------------------
> Linking...
> libcpmt.lib(xlock.obj) : error LNK2005: "public: __thiscall
> std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined
> in libcp.lib(locale.obj)
> LINK : warning LNK4098: defaultlib "LIBCMT" conflicts with use of
> other libs; use /NODEFAULTLIB:library
> Release/test1.exe : fatal error LNK1169: one or more multiply defined
> symbols found
> Error executing link.exe.
>
> test1.exe - 2 error(s), 1 warning(s)
> --------------------Configuration: test1 - Win32
> Release--------------------
>
> Any comments or suggestions would be greatly appreciated.
>
> inderpaul

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscribe@....
More information about Crypto++ and this group is available at http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---


Re: Trying to get started with Crypto++ getting linking errors

by inderpaul :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Well its been a strange journey to the say the least. I decided to
build my own test project files from scratch and this time everything
compiled and executed without any errors. Hopefully it will continue
to work in this manner from now on through.

inderpaul
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscribe@....
More information about Crypto++ and this group is available at http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---


Re: Trying to get started with Crypto++ getting linking errors

by inderpaul :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Aug 10, 8:56 am, inderpaul <inderpau...@...> wrote:

> On Aug 9, 5:10 pm, inderpaul <inderpau...@...> wrote:
>
>
>
>
>
> > Hello all again.
>
> > I'm running into one single error regarding heap memory. The exact
> > description of the error is pasted below. According to Microsoft its
> > either too much memory has been allocated for the heap or not enough.
> > I am not sure on how to fix this one even I did try a couple of things
> > but to no avail.
>
> > c:\program files\microsoft visual studio\vc98\include\xstring(78) :
> > fatal error C1076: compiler limit : internal heap limit reached; use /
> > Zm to specify a higher limit
> > Error executing cl.exe.
>
> > Here is the link to the Microsoft page if it helps anyone.http://msdn.microsoft.com/en-us/library/bdscwf1c.aspx
>
> > Best Regards
>
> I believe the included cryptest project was using the cryplib as a
> dependency therefore I should be able to create my own test
> application using the same type of setup. I was also able  to get
> around the above error by using the following switch parameter (/
> Zm200) but I am still getting the following two (2) errors:
>
> --------------------Configuration: test1 - Win32
> Release--------------------
> Linking...
> libcpmt.lib(xlock.obj) : error LNK2005: "public: __thiscall
> std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined
> in libcp.lib(locale.obj)
> LINK : warning LNK4098: defaultlib "LIBCMT" conflicts with use of
> other libs; use /NODEFAULTLIB:library
> Release/test1.exe : fatal error LNK1169: one or more multiply defined
> symbols found
> Error executing link.exe.
>
> test1.exe - 2 error(s), 1 warning(s)
> --------------------Configuration: test1 - Win32
> Release--------------------
>
> Any comments or suggestions would be greatly appreciated.
>
> inderpaul- Hide quoted text -
>
> - Show quoted text -

Found the solution for the above errors. Anyone receiving the same
error(s) please take a look at the following links

http://www.codeguru.com/forum/archive/index.php/t-414062.html
http://msdn.microsoft.com/en-us/library/72zdcz6f%28VS.71%29.aspx

Best Regards

inderpaul
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscribe@....
More information about Crypto++ and this group is available at http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---