Generate Static Lib using MSVC

Generate Static Lib using MSVC

Postby Giovany Vecchi » Tue May 03, 2022 3:11 am

When I want to create a static LIB from a DLL in BCC I use IMPLIB.
How to do this with Visual Studio Community 2022 ?
I tried with LIB but I couldn't.
User avatar
Giovany Vecchi
 
Posts: 220
Joined: Mon Jun 05, 2006 9:39 pm
Location: Brasil

Re: Generate Static Lib using MSVC

Postby carlos vargas » Wed May 04, 2022 5:01 pm

dll2lib,bat, please read use indications...
dll2lib 32 test.dll

Code: Select all  Expand view

@echo off
REM Usage: dll2lib [32|64] some-file.dll
REM
REM Generates some-file.lib from some-file.dll, making an intermediate
REM some-file.def from the results of dumpbin /exports some-file.dll.
REM Currently must run without path on DLL.
REM (Fix by removing path when of lib_name for LIBRARY line below?)
REM
REM Requires 'dumpbin' and 'lib' in PATH - run from VS developer prompt.
REM
REM Script inspired by http://stackoverflow.com/questions/9946322/how-to-generate-an-import-library-lib-file-from-a-dll
SETLOCAL
if "%1"=="32" (set machine=x86) else (set machine=x64)
set dll_file=%2
set dll_file_no_ext=%dll_file:~0,-4%
set exports_file=%dll_file_no_ext%-exports.txt
set def_file=%dll_file_no_ext%.def
set lib_file=%dll_file_no_ext%.lib
set lib_name=%dll_file_no_ext%

dumpbin /exports %dll_file% > %exports_file%

echo LIBRARY %lib_name% > %def_file%
echo EXPORTS >> %def_file%
for /f "skip=19 tokens=1,4" %%A in (%exports_file%) do if NOT "%%B" == "" (echo %%B @%%A >> %def_file%)

lib /def:%def_file% /out:%lib_file% /machine:%machine%

REM Clean up temporary intermediate files
del %exports_file% %def_file% %dll_file_no_ext%.exp
 
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
User avatar
carlos vargas
 
Posts: 1719
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua

Re: Generate Static Lib using MSVC

Postby Giovany Vecchi » Wed May 04, 2022 9:58 pm

Thanks Carlos, it worked but I had to rename the Ex functions names:
EX:
TWAIN_Acquire@4 @101 ; TWAIN_Acquire
User avatar
Giovany Vecchi
 
Posts: 220
Joined: Mon Jun 05, 2006 9:39 pm
Location: Brasil


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], Otto and 72 guests