Compatibility of *.dll *.a *.lib *.def between VisualStudio and gcc

后端 未结 4 1808
广开言路
广开言路 2020-12-29 05:15

this is very confusing. I spent a lot of time reading posts on this on stack, etc. Still confused.

I am using Qt and C++ for coding. In Qt, I am using the gcc optio

4条回答
  •  有刺的猬
    2020-12-29 06:10

    A DLL is essentially a compiled application - just in the form of a function library rather than an EXE file. Any other application can use the functions within that DLL by just declaring the function, the dll containing the function, and the parameters and return values and such.

    DLLs must already exist on a system if an application is compiled using "dynamically linked libraries", so you must either include the necessary DLLs in your installer, or hope that they already exist on the target computer. Using DLLs makes your app's size smaller overall.

    Creating DLLs is just like creating any other application - you just target your build as a DLL rather than an EXE or whatever.

    To create any application - DLL, EXE or otherwise - you need the necessary source code and headers. .h files contain declarations for functions and data types and classes and whatnot - they rarely contain code. A .def is a lot like a .h, but usually a set of instructions for a linker.

    When you compile, a .h or .c or whatever turns into a .obj - an object file. Multiple object files are linked together to create your DLL or EXE.

    A .lib file is a static library - essentially a bunch of .obj files (or one .obj) that have been combined for the linking stage.

    The format of .obj and .lib files can be particular to a compiler, and they are rarely compatible between compilers. You must have the original source code, or an .obj or .lib made specifically for your compiler.

    When you choose to make an EXE with "dynamically linked libraries", it will be expecting DLLs that it can use. When you choose "statically linked libraries", the linker will locate the .lib files it needs before producing the EXE, and you won't need those DLLs.

提交回复
热议问题