Reputation: 231
I have an legacy application which builds into exe. I am using Visual Studio 6.0 and the application is an c++ application. It used many lib files, built in VS6.0. Now i need to use the api's which in the executable. I want to create a lib file while it is creating an exe. I cannot change the code of the legacy application.
Any help is highly appreciated.
Thanks, AH
Upvotes: 0
Views: 531
Reputation: 1587
If you can't recompile your_app.exe
to mark functions as exported and force linker to produce import library, you can always generate import library (your_app.lib
) by manually creating a module definition file (your_app.def
) with names of exported functions.
An example of your_app.def
file (for full syntax check Module Definition Files documentation):
EXPORTS
AcquirePBO=_AcquirePBO@8 @1
ReleasePBO=_ReleasePBO@0 @2
The above example exports two functions from the executable which use __stdcall
calling convention (_AcquirePBO@8
and _ReleasePBO@0
) and renames them to drop the calling convention decoration. Note that specifying ordinal and renaming are optional.
To generate your_app.lib
import library from your_app.def
file you can then use LIB.EXE
command line tool:
LIB.EXE /DEF:your_app.def /MACHINE:X86 /SUBSYSTEM:WINDOWS
Make sure to adjust the /MACHINE
option.
This will produce your_app.lib
and your_app.exp
output files.
Upvotes: 0
Reputation: 185862
Create a separate library project and add any source files with APIs you want to reuse into it. It's probably cleaner to also remove those files from the exe project and make the exe project depend on the library project, but this isn't strictly necessary.
Upvotes: 1