RE: help! (DLLs)

new topic     » goto parent     » topic index » view thread      » older message » newer message

>i tried that, and no change. btw, i pedump'ed it and apparently it
>doesn't add underscores, but all compilers prepend underscores to
>function names
>

Yeah, most of them do. But only lcc keeps the underscores in the exported 
names (that I know of).

I was unable to get your example with puts("Hello World") to work. The 
function would be defined properly, but it wouldn't output anything. 
However, I do have a working example for you:


<SIMPLE.C>

  #include <windows.h>

  BOOL WINAPI __declspec(dllexport) LibMain(HINSTANCE hDLLInst, DWORD   
fdwReason, LPVOID lpvReserved)
  {
    switch (fdwReason)
    {
       case DLL_PROCESS_ATTACH:
         return TRUE;
         break;
       case DLL_PROCESS_DETACH:
         break;
       case DLL_THREAD_ATTACH:
         break;
       case DLL_THREAD_DETACH:
         break;
    }
    return TRUE;
  }


  int extern_add(int a, int b)
  {
    return a+b;
  }

</SIMPLE.C>


<SIMPLE.DEF>

  LIBRARY simple
  EXPORTS extern_add

</SIMPLE.DEF>


<SIMPLE.EXW>

  include dll.e

  atom lib,func

  lib = open_dll("simple.dll")
  func = define_c_func(lib, "_extern_add", {C_INT,C_INT}, C_INT)

  printf(1, "%d + %d = %d", {5,8,c_func(func, {5,8})})

  -- Prevent the console from being closed immediately.
  if getc(0) then end if

</SIMPLE.EXW>


I compiled the dll with:
  lcc simple.c
  lcclnk -dll -s simple.obj simple.def

(-s strips debugging stuff, or something..)

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu