BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[Linker Error] Error: Unresolved external '...' referenced f

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (WinAPI)
View previous topic :: View next topic  
Author Message
Khat
Guest





PostPosted: Tue Apr 18, 2006 3:03 pm    Post subject: [Linker Error] Error: Unresolved external '...' referenced f Reply with quote



Every once in a while I get linker errors that just don't seem to make
sense! :-(

This particular example is very simple and works no problem with Visual
Studio but not in C++ Builder 2006. The included ibs_common_crypto.h
file and it's source file are pasted at the end of this message.

I've tried starting the project from scratch, deleting object files,
anything I can think of but nothing works.

Any help with this one is very much appreceated. Thanks ...

Here's the scenario.

The following code ...:
=========
#include <string>
#include "ibs_common_crypto.h" // code for this pasted later in this
message

std::string s = "this is my secret data";
std::string ccs = ibs_crypt(s, 'e');

produces the error ...:
====
[Linker Error] Error: Unresolved external 'CryptProtectData' referenced
from D:\_SRC\IBS\SBR\QBSBR\RELEASE_BUILD\IBS_COMMON_CRYPTO.OBJ

source file:
ibs_common_crypto.h
================
#ifndef ibs_common_cryptoH
#define ibs_common_cryptoH

#include <string>
//---------------------------------------------------------------------------
std::string ibs_crypt(const std::string&, char);
#endif

ibs_common_crypto.cpp
==================
#pragma hdrstop

#include "ibs_common_crypto.h"
#include <string>
#include <vector>
#include "windows.h"
#include "wincrypt.h"

std::string ibs_crypt(const std::string& secretData, char eord) {
std::string::const_iterator i = secretData.begin();
std::string::size_type s = secretData.size();
BYTE* puc = new BYTE[s + 1];
BYTE* puc1 = puc;
while (i != secretData.end()) {
*puc = (BYTE)(*i);
++i;
++puc;
}

DATA_BLOB blobIn;

blobIn.pbData = puc1;
blobIn.cbData = s;

// Optional entropy via an external function call
DATA_BLOB blobEntropy;

blobEntropy.pbData = reinterpret_cast<BYTE *>("whatever");
blobEntropy.cbData = lstrlen(
reinterpret_cast<char *>(blobEntropy.pbData));

DATA_BLOB blobOut;
BYTE* pb;

if (eord == 'e') {
if(!CryptProtectData(
&blobIn,
NULL,
&blobEntropy,
NULL,
NULL,
0,
&blobOut)) {
// error
}
} else if (eord == 'd') {
if(!CryptUnprotectData(
&blobIn,
NULL,
&blobEntropy,
NULL,
NULL,
0,
&blobOut)) {
// error
}
}

// convert encrypted / decrypted blob to std::string
std::vector<char> crpC;
pb = blobOut.pbData;
for(DWORD dw = 0; dw != blobOut.cbData; dw++) {
crpC.push_back((char)(*pb));
pb++;
}

std::string crpt;
crpt = std::string(crpC.begin(), crpC.end());
delete [] puc1;
LocalFree(blobOut.pbData);
return crpt;
}
#pragma package(smart_init)
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (WinAPI) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.