i have a dll "lt360lib.dll" and want to create a .lib file in order to link with it. when trying to create a .def file using impdef.exe that comes with c++ builder i get the following error

"error lt360lib.dll: unknown filetype"

by the way i enter the command using command prompt as follows
"E:\>bcf\bin\impdef lt360lib.def lt360lib.dll"

since impdef was located at e:\bcf\bin directory and i also placed the lt360lib.dll there.

where is the problem
Thanks for all

Dani AI

Generated

Short practical summary tied to the thread: already got a .def out of the DLL (good). For Visual C++ the usual, reliable route is to build a Microsoft-style import library from that .def with the Microsoft Library Manager (lib.exe); if you are using a GCC/MinGW toolchain you create a MinGW-style import library (lib*.a) with dlltool (or use gendef first when you need to extract a .def). These are the standard tools and workflows. (impdef example, LIB task / lib.exe options, dlltool/gendef notes). (flylib.com)

If your goal is a Visual‑Studio import library, run the Library Manager from a Developer Command Prompt (so the tools are on PATH). Example form (replace names and machine appropriately):

lib /DEF:lt360lib.def /OUT:lt360lib.lib /MACHINE:X86

or for 64‑bit:

lib /DEF:lt360lib.def /OUT:lt360lib.lib /MACHINE:X64

Use /OUT: to control output location/name; lib will otherwise write into the current directory. See the lib.exe task/options. (learn.microsoft.com)

If you prefer MinGW/MSYS toolchain (or need a .a import lib), the common sequence is: generate a .def (if you do not have one), then run dlltool to produce the import library:

gendef lt360lib.dll      # optional: creates lt360lib.def
dlltool --def lt360lib.def --dllname lt360lib.dll --output-lib liblt360lib.a

That liblt360lib.a is what GCC/MinGW linkers use. This is the path was pointing at; it is standard for MinGW. (stackoverflow.com)

Troubleshooting the "unknown filetype" error from impdef: verify the DLL is a real Windows PE with exports before using an extractor. Use dumpbin /EXPORTS <your.dll> (or dumpbin /HEADERS) from a Visual Studio developer prompt to confirm File Type and that the exports are present. If dumpbin shows no symbols, the DLL may be stripped/packed or it may not be the file you think. Also confirm architecture (x86 vs x64) — mixing architectures will fail at link/run time. If impdef bundled with your toolchain fails, trying gendef/dlltool or the Visual Studio dumpbin + manual .def edit is a practical fallback. (dumpbin reference / options, notes on stripped DLLs and .def creation). (github.com)

Note: was correct to point at the dlltool route; was right that using a different impdef/gendef binary often fixes extractor quirks. Use the Developer Command Prompt for lib/dumpbin, and keep copies of the .def, .lib/.a, and the original DLL together so link-time and run-time artifacts match.

Recommended Answers

All 6 Replies

Doesn't impdef extract the .def file for you?
so:
"e:\>bcf\bin\impdef lt360lib.dll > lt360lib.def"

will give you the .def file, then to make the import library (.a or .lib) use dlltool with the .def you just made, and the original .dll file:
(see )

Thanks for the reply my friend
when i try to use

"e:\>bcf\bin\impdef lt360lib.dll > lt360lib.def"

i get this

"Syntax: IMPDEF [options] destname[.def] srcname[.dll]
Options:
-h Emit hints
"
and another question where should the output be located, is it in the same directory where the impdef.exe is located ?
i.e
"e:\>bcf\bin\lt360lib.def"
thanks again

Thanks for the reply my friend
when i try to use

"e:\>bcf\bin\impdef lt360lib.dll > lt360lib.def"

i get this

"Syntax: IMPDEF [options] destname[.def] srcname[.dll]
Options:
-h Emit hints
"
and another question where should the output be located, is it in the same directory where the impdef.exe is located ?
i.e
"e:\>bcf\bin\lt360lib.def"
thanks again

I think dougy83 referred to another (somewhat simplified) impdef utility which you can find here
http://mirrors.zoreil.com/webclub.kcom.ne.jp/ma/colinp/gcc.html

So you might give that one a try, using the command:

impdef lt360lib.dll > lt360lib.def

yupee it worked i have a .def file but , i use a VC++ does it have a dlltool and where is it usually located
Thanks

I have it at the following locations:

C:\Dev-Cpp\bin\dlltool.exe
C:\Dev-Cpp\mingw32\bin\dlltool.exe

But that's because I use dev-c++ (mingw) not VC++. You should be able to download it from the net. Try googling it.

Thanks for the reply i think i found it is in the bin folder it called lib.exe thanks again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.