How can I call a C ++ win32 dll from another c ++ win32 console application

What is my main problem: I can write C ++ dll using VC ++. Now the dll is present in the Debug folder.

How can I use my DLL in another C ++ console application. How to add a link or associate a DLL with an application.

Another point. Creating a DLL, the VC ++ wizard gives me the opportunity:

  • Empty dll project
  • Simple dll project
  • Dll that exports some character

Now, according to the article from CP, I used the third option. (Failed to complete because the DLL was used by the MFC application, some of which are slightly advanced at this point in time)

Should I always choose the third option? What do the other two options mean?

+3
source share
4 answers

Not quite sure about your questions:

It doesn’t really matter which option you use, it’s just a matter of what the wizard does for you; if you use the third option, the wizard creates a bit in your header file that looks like this:

#ifdef TEST_EXPORTS
#define TEST_API __declspec(dllexport)
#else
#define TEST_API __declspec(dllimport)
#endif

, , DLL TEST_EXPORTS , TEST_API dllexport, . , TEST_API dllimport, , DLL. #define .

/ DLL, : a) __declspec (dllexport) [ ] ) .DEF

, DLL .exe .lib, DLL.

+6

"DLL, ", , Dll. , " DLL". "DLL, ", , , // .

.Dll , .lib : Project - Properties - Linker - Input - Additional Dependencies. , .lib , , .lib, . : (Project - Properties - Linker - General - ) V++ (Tools - Options - V++ Directories - Libraries).

, DLL .exe . Dll , , Windows, PATH.

+3

DLL , Console Visual Studio, . , DLL, DLL , PATH. DLL LoadLibrary (. http://msdn.microsoft.com/en-us/library/ms684175(VS.85).aspx) , DLL, GetProcAddress (. http://msdn.microsoft.com/en-us/library/ms683212(VS.85).aspx).

+2

, .   http://msdn.microsoft.com/en-us/library/ms235636.aspx

   DLL.   . ,    .

  • DLL , DLL . , . " " β†’ "", - " (DLL)". , "", " " .

  • , . DLL , . lib, . lib , dll. Visual Studio debug mode, Project β†’ Folder β†’ Debug. , β†’ Release. lib , β†’ β†’ β†’ β†’ lib ( "AFR24x7.lib" ).

  • , .lib , , .lib . : (Project β†’ Properties β†’ Linker β†’ General β†’ ) , V++ ( β†’ β†’ V++ β†’ ).

  • , .

  • DLL ( ).

  • , .

, .

+1

Source: https://habr.com/ru/post/1761677/


All Articles