Image

Imageeurijk wrote in Imagecpp 😛determined

Win32 DLL Load Time Symbol Resolution

I've been working on a opensource project http://prolix.sourceforge.net/ (as if it matters what it is :D) and have been having some rather large problems converting over to win32.

class MyModule : public Base {
  ...


The problem with this is the dll can not look up the symbol for Base and all it's members, so in the event of:

class MyModule : public Base {
  void f1( void) { ... }
  ...


class Base {
  virtual void f1( void) { ... }
  virtual void f2( void) { ... lots o stuff ... }
  ...


The dll will never make because it doesn't know where to find function f2. I think a very basic demo of this problem would be:

//===
// dll.cpp
...includes etc...
extern int bar;

export "C" _declspec(dllexport) void foo( void) {
  printf("Bar is %d\n", bar);
}


and

//===
// main.cpp
...includes...
int bar = 1;
int main( void) {
  printf("Loading dll\n");
  HMODULE hndl = LoadLibrary( "dll.dll");
  if (!hndl) {
    printf("Error: Unable to load dll.dll\n");
    return -1;
  }

  void (*fnct)( void);
  (void *)fnct = (void *)GetProcAddress( hndl, "foo");

  if (!fnct) {
    printf("Error: Unable to find foo\n");
    return -1;
  }

  (*fnct)();

  FreeLibrary( hndl);
  return 0;
}



or whatever... (mach attempt @ src demo :D)

Is this possible in windows or can dll's not look up functions/variables of the program that is loading it?

I am using gcc w/ libtool and all if it helps.
Any advice would be much appreciated! >;-)

thanks
-eurijk!