Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can call one function, but not the other

Status
Not open for further replies.

jamez05

Programmer
Jul 29, 2005
130
US
I'm creating a C++ MFC dll using Visual Studio 2005.
I can call "CALCCMR" successfully from a dll, but not "CALCCLOGP". Here's the code that calls the dll:
Code:
// import DLL functions
typedef long (CALCLOGP)(const char*, float*, long*, HANDLE*);
typedef long (CALCCMR)(const char*, float*);
typedef long (CALCXMR)(const char*, float*);
typedef long (CALCMGVOL)(const char*, float*);
typedef long (MOL_FILE_IMPORT) (char* inputF, char* outputF);
typedef double (CLOGP_VIA_MOL) (char* myMol);

static CALCLOGP* calcLogP = NULL;
static CALCCMR* calcCMR = NULL;
static CALCXMR* calcXMR = NULL;
static CALCMGVOL* calcMgVol = NULL;
static MOL_FILE_IMPORT* mol_file_import;
static CLOGP_VIA_MOL* clogp_via_mol;
static HINSTANCE hinstCLogP = NULL;
static HINSTANCE hinstCopy = NULL;

In my main function, I follow the directions provided with the 3rd party dll:
Code:
//Complete the import of the dll routines
hinstCLogP = LoadLibrary("bb-clogp.dll");
hinstCopy = hinstCopy;

calcLogP = (CALCLOGP *) GetProcAddress(hinstCLogP, "calcLogP");
calcCMR = (CALCCMR *) GetProcAddress(hinstCLogP, "calcCMR");
calcXMR = (CALCXMR *) GetProcAddress(hinstCLogP, "calcXMR");
calcMgVol = (CALCMGVOL *) GetProcAddress(hinstCLogP, "calcMgVol");
mol_file_import = (MOL_FILE_IMPORT *) GetProcAddress(hinstCLogP, "mol_file_import");
clogp_via_mol = (CLOGP_VIA_MOL *) GetProcAddress(hinstCLogP, "clogp_via_mol");

The instructions show how to call these function, but leave out/not explain some of the variables being passed. For example, there is no reference to a variable named Smiles. However, this is the value being passed to the dll, so if I hard-code it, it works when I try calcCMR(Smiles, &pCMR):

Code:
long err;
float pCMR;

err = calcCMR("O=C", &pCMR);

I run this and it compiles fine.

Here's the example for calculating calcLogp:

Code:
float pLogP;
long err;

long pNumContrb;

// Note: These MUST be GlobalFree( ) 'd after calls to calcLogP
LogPContribution** pClogPContrb, * pclogp;


pLogP = -99.99f;
pNumContrb = 0;

err = calcLogP(smiles, &pLogP, &pNumContrb, &pClogPContrb);

// smiles holds the smiles string of course.
// pLogP will have your value if err is less than 60.

// Later you must free as follows...
//	GlobalFree(pClogPContrb);
//	GlobalFree(pclogp);

When I compile this, I get the following errors:
Code:
c:\documents and settings\epajn\my documents\visual studio 2005\projects\cfx_clogp\request.cpp(62) : error C2065: 'LogPContribution' : undeclared identifier
c:\documents and settings\epajn\my documents\visual studio 2005\projects\cfx_clogp\request.cpp(62) : error C2065: 'pClogPContrb' : undeclared identifier
c:\documents and settings\epajn\my documents\visual studio 2005\projects\cfx_clogp\request.cpp(62) : error C2065: 'pclogp' : undeclared identifier

There is no other additional information about the type for these variables, and I'm new to C++ so don't know what I'm missing.
I've tried declaring these variables according to what's being imported, but still get errors. Does anyone have any insight?
 
It is basically telling you that it doesn't have the definition of LogPContribution. If you don't know what it is, you could forward declare it before using it. eg
Code:
class LogPContribution;
LogPContribution** pClogPContrb;
LogPContribution* pclogp;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top