C语言 使用 VC++ 命令行创建 .dll 和 .lib 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2727187/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 05:18:29  来源:igfitidea点击:

Creating .dll and .lib files with the VC++ command line

cvisual-c++

提问by Vineel Kumar Reddy

How can I create .libfiles and .dllfiles in VC++ with cl.exefrom the command line?

如何从命令行在 VC++ 中创建.lib文件和.dll文件cl.exe

回答by CB Bailey

Visual Studio comes with a library tool called LIB.EXEwhich can be used to create library files from object files. If you set up the command line so that you have CL.EXEon the path, you should also be able to run LIB.EXE.

Visual Studio 附带一个名为的库工具LIB.EXE,可用于从目标文件创建库文件。如果您设置了命令行以便CL.EXE在路径上,您还应该能够运行LIB.EXE.

E.g.

例如

LIB.EXE /OUT:MYLIB.LIB FILE1.OBJ FILE2.OBJ

To create a dll, you just use LINK.EXE(as for executables) but with the /DLLswitch.

要创建 dll,您只需使用LINK.EXE(对于可执行文件),但要使用/DLL开关。

E.g.

例如

LINK.EXE /DLL /OUT:MYLIB.DLL FILE3.OBJ FILE4.OBJ

回答by Alex Budovski

Re making a DLL, these are shorthand form(s) if you have the source files:

重新制作一个 DLL,如果你有源文件,这些是速记形式:

cl /LD foo.c bar.c baz.c /FeMyImage.dll

or

或者

cl /LD foo.c bar.c baz.c /link /out:MyImage.dll

are equivalent.

是等价的。