//project1
///DLL. H
# ifdef DLLMOUDLE
# define EXPORT __declspec (dllexport)
# the else
# define EXPORT __declspec (dllimport)
# endif
The class EXPORT A
{
Public:
Void print_b ();
}
///DLL. CPP
Void A: : print_b (void)
{
Printf (" BBBBBBBBBBBBBB ")
}
//project2
//the main CPP
# include DLL. H//on the path of the
Void main ()
{
A * A=new A ();
A - & gt; Print_b ();
}
Project 1 and 2 in the same solution, rely on project1 project2,
Generate solutions, to create a connection error, cannot resolve the external symbol of print_b, if I put the realization of the print_b header file DLL. H can be compiled, help you a great god why!!! Be urgent!! Urgent!!
CodePudding user response:
Your project2 engineering without introducing project1 import libraries, so natural link program cannot find symbols,
You put the print_b DLL. Compiled in h, equivalent to direct links to the static compilation,
CodePudding user response:
reference 1st floor FASM_FASM response: your project2 engineering without introducing project1 import libraries, so the natural link program cannot find symbols, You put the print_b DLL. Compiled in h, equivalent to direct links to the static compilation, You said import libraries refers to DLL. Lib? I don't have to generate the lib is pure DLL, __declspec (dllexport) derived this way doesn't seem to need the lib class reference?? Pray god to explain CodePudding user response:
Any way to export and import of DLL implementation must have a link to the body. (lib) file, and the lib files are automatically generated, don't need you to explicitly specify, in the header file __declspec (dllexport) is a kind of indicates a specific statement on the import (used to tell the compiler doesn't need to generate a function call jump statements, but direct call), CodePudding user response:
reference FASM_FASM reply: 3/f any way export, import of DLL implementation must have a link to the body. (lib) file, and the lib files are automatically generated, don't need you to explicitly specify, in the header file __declspec (dllexport) is a kind of indicates a specific statement on the import (used to tell the compiler doesn't need to generate a function call jump statements, but direct call), Automatically generate the lib in which directory? I can't search CodePudding user response:
Depends on how you use the programming tool, if is VC, the default in project directory (debug) or (release) directory, CodePudding user response:
reference 5 floor FASM_FASM reply: depends on how you use the programming tool, if is VC, the default in project directory (debug) or (release) directory, I use vs2015 CodePudding user response:
reference FASM_FASM reply: 3/f any way export, import of DLL implementation must have a link to the body. (lib) file, and the lib files are automatically generated, don't need you to explicitly specify, in the header file __declspec (dllexport) is a kind of indicates a specific statement on the import (used to tell the compiler doesn't need to generate a function call jump statements, but direct call), I have a problem is that now there are a lot of DLL is directly into exe directory can directly use the inside of the function or class, the DLL has not lib CodePudding user response:
refer to 7th floor qq_15575737 response: Quote: reference FASM_FASM reply: 3/f Any way to export and import of DLL implementation must have a link to the body. (lib) file, and the lib files are automatically generated, don't need you to explicitly specify, in the header file __declspec (dllexport) is a kind of indicates a specific statement on the import (used to tell the compiler doesn't need to generate a function call jump statements, but direct call), And I have a problem is that now there are a lot of DLL is directly into exe directory can directly use the inside of the function or class, the DLL has not lib. .lib file just for the executable files link operation, that is to say the executable files are generated after there is no need for him, so the execution environment, without it, CodePudding user response:
In your project1 added in the header file # pagram (lib, \ "the lib directory you exported DLL file path") ok CodePudding user response:
With.lib file. Just as important as the DLL,,,, the source code in the compiled, in. Will generate symbols in the LIB directory, is all sorts of function names, but not including function performs code. But your application project1 at compile time, need to found the corresponding symbol in the source code, and thus to link and therefore requires project2..lib file to provide the corresponding symbol information, the link here is just a symbolic link, will not increase your file size, because do not contain the executive body. Just need to perform as you say. The DLL file is because DLLS need dynamically loaded into memory, and your project1 when performing dynamic according to link the symbol table, find the DLL in memory, find the corresponding executive body, to perform. So you release. EXE file, you need to provide. DLL files together, but I don't need to provide. LIB... In plain English, the LIB is developers to build connection with, the DLL is user, use when running the program... CodePudding user response:
Relevant details, please refer to the god for & lt; Programmers self-improvement - compile, link, and pants & gt;