Essien Essien wrote: > hiya, > > I have a code snippet that looks like: > > typedef int (*SQLITE3_CLOSE)(sqlite3*); > typedef const char* (*SQLITE3_ERRMSG)(sqlite3*); > typedef int (*SQLITE3_OPEN)(const char*, sqlite3**); > typedef int (*SQLITE3_EXEC) (sqlite3*, const char*, sqlite3_callback, void*, > char**); > > HINSTANCE sqlite3_dll; > > SQLITE3_CLOSE _sqlite3_close; > SQLITE3_ERRMSG _sqlite3_errmsg; > SQLITE3_OPEN _sqlite3_open; > SQLITE3_EXEC _sqlite3_exec; > > int DB_Init() > { > sqlite3_dll = LoadLibrary("sqlite3.dll"); > if (sqlite3_dll == NULL) { > printf("Cannot find sqlite3.dll. Make sure its in the same > directory as the program\n"); > return 0; > } > > _sqlite3_open = (SQLITE3_OPEN)GetProcAddress(sqlite3_dll, > "sqlite3_open"); > if (_sqlite3_open == NULL) { > printf("Cannot load function sqlite3_open"); > return 0; > } > } > > problem is, when ever i call DB_Init(), it always fails with 'Cannot load > function sqlite3_open'. But it successfully passes the LoadLibrary portion. > I'm not a win32 guru, so i'm willing to admit i've made a mistake somewhere. > > Any ideas on what i'm doing wrong? > > I'm using Turbo C++ 4.5 IDE and related tools. (yeah... i know turbo > C++ 4.5is realy aged, but could this be the problem?) > > Essien > >
Since you have the borland compiler product, use the "TDUMP.EXE" tool to view the PE header of the sqlite3.dll file. Sometimes the functions will be exported with a leading underscore. If your compiler is producing 32 bit binaries, and the DLL is also 32 bit, then you might try adding a leading underscore to the symbol name when you call 'GetProcAddress'.