Compile a DLL in C/C++, then call it from another program

前端 未结 5 1161
死守一世寂寞
死守一世寂寞 2020-11-27 09:12

I want to make a simple, simple DLL which exports one or two functions, then try to call it from another program... Everywhere I\'ve looked so far, is for complicated matter

5条回答
  •  自闭症患者
    2020-11-27 10:11

    The thing to watch out for when writing C++ dlls is name mangling. If you want interoperability between C and C++, you'd be better off by exporting non-mangled C-style functions from within the dll.

    You have two options to use a dll

    • Either use a lib file to link the symbols -- compile time dynamic linking
    • Use LoadLibrary() or some suitable function to load the library, retrieve a function pointer (GetProcAddress) and call it -- runtime dynamic linking

    Exporting classes will not work if you follow the second method though.

提交回复
热议问题