linking problems

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Aug 2006
Posts: 2
Reputation: Ripiz is an unknown quantity at this point 
Solved Threads: 0
Ripiz Ripiz is offline Offline
Newbie Poster

linking problems

 
0
  #1
Aug 12th, 2006
md5.cpp
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <string>
  4. #include <stdio.h>
  5. #include "md5.h"
  6. using namespace std;
  7. char* szString = "Some string you want to generate an MD5 key for.";
  8. int main(int argc, char *argv[])
  9. {
  10. char* sString = MD5String(szString);
  11. cout << "Some string you want to generate an MD5 key for." << "MD5 Output: " << sString;
  12. system("PAUSE");
  13. return EXIT_SUCCESS;
  14. }

md5.h
  1. typedef unsigned int uint4;
  2. typedef unsigned short int uint2;
  3. typedef unsigned char uchar;
  4. char* PrintMD5(uchar md5Digest[16]);
  5. char* MD5String(char* szString);
  6. char* MD5File(char* szFilename);
  7. class md5
  8. {
  9. public:
  10. md5() { Init(); }
  11. void Init();
  12. void Update(uchar* chInput, uint4 nInputLen);
  13. void Finalize();
  14. uchar* Digest() { return m_Digest; }
  15. private:
  16. void Transform(uchar* block);
  17. void Encode(uchar* dest, uint4* src, uint4 nLength);
  18. void Decode(uint4* dest, uchar* src, uint4 nLength);
  19. inline uint4 rotate_left(uint4 x, uint4 n)
  20. { return ((x << n) | (x >> (32-n))); }
  21. inline uint4 F(uint4 x, uint4 y, uint4 z)
  22. { return ((x & y) | (~x & z)); }
  23. inline uint4 G(uint4 x, uint4 y, uint4 z)
  24. { return ((x & z) | (y & ~z)); }
  25. inline uint4 H(uint4 x, uint4 y, uint4 z)
  26. { return (x ^ y ^ z); }
  27. inline uint4 I(uint4 x, uint4 y, uint4 z)
  28. { return (y ^ (x | ~z)); }
  29. inline void FF(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
  30. { a += F(b, c, d) + x + ac; a = rotate_left(a, s); a += b; }
  31. inline void GG(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
  32. { a += G(b, c, d) + x + ac; a = rotate_left(a, s); a += b; }
  33. inline void HH(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
  34. { a += H(b, c, d) + x + ac; a = rotate_left(a, s); a += b; }
  35. inline void II(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
  36. { a += I(b, c, d) + x + ac; a = rotate_left(a, s); a += b; }
  37. private:
  38. uint4 m_State[4];
  39. uint4 m_Count[2];
  40. uchar m_Buffer[64];
  41. uchar m_Digest[16];
  42. uchar m_Finalized;
  43. };

I get this error
[Linker error] undefined reference to `MD5String(char*)'

Help please
Last edited by Ripiz; Aug 12th, 2006 at 12:06 pm.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 148
Reputation: Micko is on a distinguished road 
Solved Threads: 6
Micko Micko is offline Offline
Junior Poster

Re: linking problems

 
0
  #2
Aug 12th, 2006
Where and how didi you define your MD5String function?
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2
Reputation: Ripiz is an unknown quantity at this point 
Solved Threads: 0
Ripiz Ripiz is offline Offline
Newbie Poster

Re: linking problems

 
0
  #3
Aug 12th, 2006
I don't know C++ language, just learning now, copied this code from some old post(I think), how to define it?

Thanks for your help
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,651
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 474
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: linking problems

 
0
  #4
Aug 12th, 2006
It would be really better if you start from the basics rather than jumping in the middle of nowhere. If you dont understand the code there is no point in makin it run.

Still if you want the working code, you can try a new implementation of the MD5 algorithm HERE.

Hope it helped,
Bye.
I don't accept change; I don't deserve to live.

Jo Tujhe Jagaaye, Nindein Teri Udaaye Khwaab Hai Sachcha Wahi.
Nindon Mein Jo Aaye Jise To Bhul Jaaye Khawab Woh Sachcha Nahi.
Khwaab Ko Raag De, Nind Ko Aag De
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum


Views: 1016 | Replies: 3
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC