Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c

visual-c++

How can I create .lib files and .dll files in VC++ with cl.exe from the command line?

like image 843
Vineel Kumar Reddy Avatar asked Apr 28 '10 06:04

Vineel Kumar Reddy


People also ask

How do I create a DLL and lib in Visual Studio?

To create a DLL project in Visual Studio 2019On the menu bar, choose File > New > Project to open the Create a New Project dialog box. At the top of the dialog, set Language to C++, set Platform to Windows, and set Project type to Library.

How do I create a .LIB file?

On the Application Settings page of the Win32 Application Wizard, under Application type, select Static library. On the Application Settings page of the Win32 Application Wizard, under Additional options, clear the Precompiled header check box. Press Finish to create the project.

How a DLL can be created using MFC?

To create an MFC DLL Project using the MFC DLL WizardDefine your application settings using the application settings page of the MFC DLL Wizard. Skip this step to keep the wizard default settings. Click Finish to close the wizard and open your new project in Solution Explorer.


2 Answers

Visual Studio comes with a library tool called LIB.EXE which can be used to create library files from object files. If you set up the command line so that you have CL.EXE on the path, you should also be able to run 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 /DLL switch.

E.g.

LINK.EXE /DLL /OUT:MYLIB.DLL FILE3.OBJ FILE4.OBJ 
like image 106
CB Bailey Avatar answered Oct 13 '22 01:10

CB Bailey


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

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.

like image 40
Alex Budovski Avatar answered Oct 12 '22 23:10

Alex Budovski