Like dllimport in Microsoft Visual C ++

I have a DLL, and I would like to use some of its functions.

#include <iostream>

using namespace std;

extern "C" __declspec(dllimport) int Initialize(char* localPort, char* adminServerName, int rpcTimeout);


int main()
{
    int res = Initialize("7864", "6000@kabc", 10000);

    return 0;
}

I don't have a .lib dll, so I can still link it. One thing that comes to my mind is to use the LoadLibrary function and then use GetProcAddress (). Is there another way?

When I compile the following code

  • error LNK2019: unresolved external symbol _imp_Initialize refers to the _main function

  • fatal error LNK1120: 1 unresolved external

I get the above errors

I am using Windows and Visual Studio 2008

+5
source share
3 answers

, Dev Studio .

dll, V++ .lib, . .lib dll LoadLibrary GetProcAddress.

, , dll, DLL- V++, , , .lib DLL.

: , dll, - .

"" DLL dependencywalker

  • "" - .DEF, extern "C" __declspec(dllexport) int __cdecl Initialize(...
  • "_ Initalize @16" - : extern "C" __declspec(dllexport) int __stdcall Initialize(...
  • ? Initialize @@YAHPADOH @Z "-` __declspec (dllexport) int (char *, char *, int);
  • ? @@YGHPADOH @Z "-` __declspec (dllexport) int __stdcall (char *, char *, int);

- - __cdecl ( dll api __stdcall - DLL Windows - __stdcall), .def .

+4

, , . / .

strings ( cygwin), DLL. , 0 ( , , , cygwin). "" ​​ , ++ (. http://en.wikipedia.org/wiki/Name_mangling). , , undname.exe (, DLL Microsoft Visual, . http://msdn.microsoft.com/en-us/library/5x49w699.aspx)

... , DependencyWalker.

+1

DLL, .

, :

+1

All Articles