I am getting a runtime error:  symbol not found.  In the following code the
error arises in the call to dlsym().  Since I getting no problem in
compiling and linking the library, I am curious what might be going wrong
with this library call.

Suggestions?

Stephen



// bank.c

#ifdef WIN32
 #include "windows.h"
#endif

#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
#include "bank40.h"

typedef double
*GFP)( double,double,int,int,int,int,int,int,double,double,int,int,int );

int main(int argc, char* argv[])
{
 void *hLib;
 GFP GetFailureProbability;
 const char *cpError;
 double dReturn = 0,
     dCapitalAssetRatio = 0,
     dUnemploymentRate = 0,
     dBankMargin = 0,
     dBadAssets = 0
     ;
 int iAssetSize = 0,
  iCAMEL = 0,
  iFailT1 = 0,
  iCharterAge = 0,
  iMBHC = 0,
  iHotMoney = 0,
  iTime = 0,
  iSimYear = 0,
  iModelNum = 0
  ;

 hLib = dlopen("libbank40.so", RTLD_LAZY);
 if ( hLib == NULL )
 {
  fprintf(stderr, "libbank40.so not found:  %s\n", dlerror());
  exit(1);
 }

 // Begin test values
 dCapitalAssetRatio = 10.1;
 dUnemploymentRate = 5.1;
 dBankMargin = 1.1;
 dBadAssets = 0;
 iAssetSize = 0;
 iCAMEL = 0;
 iFailT1 = 4;
 iCharterAge = 0;
 iMBHC = 0;
 iHotMoney = 0;
 iTime = 5;
 iSimYear = 2000;
 iModelNum = 3;
// End test values

 dlerror();
 GetFailureProbability = dlsym( hLib,"GetFailureProbability" );
 cpError = dlerror();
 if ( cpError )
 {
  fprintf( stderr, "GetFailureProbability() not found: %s\n", cpError );
  exit(1);
 }

    dReturn = GetFailureProbability(dCapitalAssetRatio,
         dUnemploymentRate,
         iAssetSize,
         iCAMEL,
         iFailT1,
         iCharterAge,
         iMBHC,
         iHotMoney,
         dBankMargin,
         dBadAssets,
         iTime,
         iSimYear,
         iModelNum );

 printf("\n%f\n", dReturn);

 dlclose( hLib );
 return 0;
}



Reply via email to