Ok, So I've been going through the various cases for this error and so far I have not been able to figure out exactly what is causing it this time (I am a little dyslexic, so apologies if it is staring me in the face) I keep finding references to problems like this: Undefined reference to main - collect2: ld returned 1 exit status and QtCreator build returns collect2: ld returned exit status 1 but these types of cases don't seem to fit.
I am writing a program that will automatically re-sign a message after it's been edited. The signing function takes in some information, hashes it with md5 (I know, but legacy requirements), and then encodes the output with Base64 (which takes a series of bytes via const unsigned char*, and the total size of the message)
I first tried Crypto++ libray for MD5, and it would provide expansion in the future for other hashes and protocols. After a massive number of undefined reference errors in the linking stage, I tried another md5 implementation I found online. This one gives me only two linking errors, but I think they may be caused by the same reason so I'll go with the second library to save post space.
A snippet of my C++ code for the message signing:
string createMessageSignature(string input)
{
//byte digest[ CryptoPP::MD5::DIGESTSIZE ];
//CryptoPP::MD5().CalculateDigest( digest, (byte*) input.c_str(), input.length() );
//cout << "md5 signature: " << digest << endl;
//string encodedDigest = base64_encode(digest, 32);
int size = md5(input).length();
string stringDigest = md5(input);
const unsigned char* digest = reinterpret_cast<const unsigned char*>(stringDigest.c_str());
cout << "md5 signature hash: " << digest << endl;
string encodedDigest = base64_encode(digest, size);
cout << "signature base64 encoded: " << encodedDigest << endl;
return encodedDigest;
}
The md5 library I'm currently using is here: http://www.zedwood.com/article/121/cpp-md5-function (though I want to move to Crypto++ in the end, or maybe OpenSSL).
Error Messages from Linker (using MinGW on Win7, though also happens on GCC in a linux environment):
C:\Users\j********\Desktop\MessageSigner>C:/MinGW/bin/g++ -o MessageSigner.exe M
essageSigner.cpp
C:\Users\J****~1\AppData\Local\Temp\ccLejcEo.o:MessageSigner.cpp:(.text+0xc54):
undefined reference to `md5(std::string)'
C:\Users\J****~1\AppData\Local\Temp\ccLejcEo.o:MessageSigner.cpp:(.text+0xc9f):
undefined reference to `md5(std::string)'
collect2: ld returned 1 exit status
Any thoughts? Everything seems defined, and the code compiles. I've never had much experience debugging linker errors. Only compile option I've been using is -o for a file name, '-o MessageSigner.exe'
-Jimmy