Home > Back-end >  Of new, ask a few questions about the.lib file
Of new, ask a few questions about the.lib file

Time:01-13

Of new, ask a few questions about the.lib file:

Lib file is divided into static and dynamic, right? Static contains implementation, dynamic contains statement, equivalent to a header file right?
If is static, then there is no DLL, right?

Question:
1. If you add the.lib file/link, also need a header file? Because three party libraries such as sqlite download, there is def files, and DLL files, can generate.lib file, but no header files, because do not need?

2. I have done a bit of dynamic library written in C language, are generated DLL file, through the # include "XXX. H" to use my DLL, why I don't need to generate the lib? What is the meaning of the lib exist?

CodePudding user response:

C/c + + into executable files need to be in two steps, compile + links, compiled the result is an intermediate obj files or lib, each c, or CPP compilation unit, can form a obj, link is the intermediate files and other files such as resources, combine to exe files,
1, link the lib, need header files, because some of the statement is defined as a header file to compile process, the DLL is executable file, use the DLL doesn't have to because it can use loadlibrary lib and h file, and two getprocessaddress API to obtain the output function of address, direct execution, so also called binary reuse,
2, your lib may have add to your project, it's just you didn't find,

CodePudding user response:

reference 1/f, the truth is right or wrong response:
c/c + + into executable files need to be in two steps, compile + links, compiled the result is an intermediate obj files or lib, each c, or CPP compilation unit, can form a obj, link is the intermediate files and other files such as resources, combine to exe files,
1, link the lib, need header files, because some of the statement is defined as a header file to compile process, the DLL is executable file, use the DLL doesn't have to because it can use loadlibrary lib and h file, and two getprocessaddress API to obtain the output function of address, direct execution, so also called binary reuse,
2, your lib may have add to your project, it's just you haven't found,
I DLL written in c, the compiler is under the command line, and with the GCC, then copy to the project directory, and header files, certainly no lib

CodePudding user response:

reference at the 2nd floor response:
Quote: reference 1/f, the truth is right or wrong response:
c/c + + into executable files need to be in two steps, compile + links, compiled the result is an intermediate obj files or lib, each c, or CPP compilation unit, can form a obj, link is the intermediate files and other files such as resources, combine to exe files,
1, link the lib, need header files, because some of the statement is defined as a header file to compile process, the DLL is executable file, use the DLL doesn't have to because it can use loadlibrary lib and h file, and two getprocessaddress API to obtain the output function of address, direct execution, so also called binary reuse,
2, your lib may have add to your project, it's just you haven't found,
my DLL written in c, the compiler is under the command line, and with the GCC, then copy to the project directory, and header files, certainly no lib

Stick your example

CodePudding user response:

reference 3 floor truth is right or wrong response:
Quote: refer to the second floor administrator reply:
Quote: reference 1/f, the truth is right or wrong response:
c/c + + into executable files need to be in two steps, compile + links, compiled the result is an intermediate obj files or lib, each c, or CPP compilation unit, can form a obj, link is the intermediate files and other files such as resources, combine to exe files,
1, link the lib, need header files, because some of the statement is defined as a header file to compile process, the DLL is executable file, use the DLL doesn't have to because it can use loadlibrary lib and h file, and two getprocessaddress API to obtain the output function of address, direct execution, so also called binary reuse,
2, your lib may have add to your project, it's just you haven't found,
my DLL written in c, the compiler is under the command line, and with the GCC, then copy to the project directory, and header files, certainly no lib

Stick your example out

//func. C 
# ifdef _MSC_VER
# define DLL_EXPORT __declspec (dllexport)
# the else
# define DLL_EXPORT
# endif

DLL_EXPORT int the add (int a, int b)
{
Return a + b;
}

DLL_EXPORT void print_s (const char * s)
{
Printf (" Hello, % s ", s);
}


Compiler:
GCC func. C - Shared - o func. DLL

CodePudding user response:

According to load you just need to DLL, implicit load need lib and header files

CodePudding user response:

Please refer to the "VS2015 dynamic library programming based article resource summary"
Wish I could help you!
  • Related