Menu

Importing function from DLL

2002-10-19
2012-09-26
  • Nobody/Anonymous

    I have a DLL that I made with MSVC 6 and a little utility program that needs to import one function from the DLL. It compiles under MSVC but not with Dev-C++ 4.9.5.0. It gives me "Undefined reference to import stub for <MyFunction>"

    I have a libxxx.a file made with dlltool included in the lib directories path, and I've tried various combinations of the -l switch to the linker including the full path to the lib file.

    The header file has;
    __declspec (dllimport) int MyFunction (char*, int);
    And the source file is calling it normally;
    MyFunction (szBlahBlah, 1);

    I know the dll works fine! What is going wrong?
    Thanks in advance..

    Geoff

     
    • Nobody/Anonymous

      Anyone, Please help Geoff because I'm having the same problem.
      I tried among other things to follow suggestions in MinGW FAQ "How can an MSVC program call a MinGW DLL, and Vice Versa", but without success.
      kisses,

      Hein

       
    • Nobody/Anonymous

      My example: I built the Berkely DB dll using VC6. Included the header in my source, it contained only the standard prototypes without any decl or dllimport or whatever. Renamed the import lib VC built for the dll to libdb40.a and added to gcc linker with -ldb40. Done.
      Harder: the VC import lib does not link, so we have to build a gcc version. If we have a def file with the imports dlltool builds one nice import lib from it. Almost worked with MySql, but not quite (stack size missing).
      Harder yet: if there's no def file, reimp can create one from the VC import lib. On the Berkeley DB lib it failed unfortunately, but it was the good MySql solution.
      Even harder: pexport can create the def file from the dll itself (so I was told), which I never tried.
      Paranoid: creating the def by hand, scanning the dll for exported functions with a text viewer. Never tried.

      I'm a lucky entry level guy, I use only two dll's regularly (Berkely and MySql, both built with VC) without having to dive into this decl..dllimport stuff.

      rpeter

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.