Create .lib file from .dll

When working with 3rd party win dll’s you somtimes miss the according .lib file required to compile against it. There is a MS KB article showing how to generate a .lib file from a .dll, however the required steps are not described detailed enough I think. So here is my quick guide:

Open the Visual Studio Command Prompt, you find its shortcut in Start->Programs->Microsoft Visual Studio->Tools. Now run the dumpbin command to get a list of all exported functions of your dll:

dumpbin /exports C:\yourpath\yourlib.dll

This will print quite a bit of text to the console. However we are only interested in the functions:

ordinal hint RVA      name

1    0 00017770 jcopy_block_row
2    1 00017710 jcopy_sample_rows
3    2 000176C0 jdiv_round_up
4    3 000156D0 jinit_1pass_quantizer
5    4 00016D90 jinit_2pass_quantizer
6    5 00005750 jinit_c_coef_controller

Now copy all those function names (only the names!) and paste them into a new textfile. Name the nextfile yourlib.def and put the line “EXPORTS” at its top. My yourlib.def file looks like this:


Now from that definition file, we can finally create the .lib file. We use the “lib” tool for this, so run this command in your Visual Studio Command Prompt:

lib /def:C:\mypath\mylib.def /OUT:C:\mypath\mylib.lib

That’s it, happy coding 🙂


74 Responses to “Create .lib file from .dll”

  1. 1 Mark Bosold March 26, 2009 at 4:33 pm

    Thanks so much for your concise explanation of creating a .lib file. I dislike going to MSDN to find out how to solve simple problems. I find I must read and digest a lot of information before I can apply it to my immediate problem. Its sites like yours that make development fun! Thanks again, Mark

  2. 2 Balaji Badam July 13, 2009 at 6:14 am

    Totally agree with the posting above, Thank you very much for the simple instructions. Really save me a lot of time. I do not know why msdn cannot be as simple as that.

  3. 3 Abhishek Dey June 20, 2010 at 8:11 am


    Thanks for this great Article. One last thing, How can i redirect the dumpbin’s output directly to a file instead of copying each function name ?

    Thanks and Regards,


  4. 7 ramesh prasad April 19, 2011 at 7:28 am

    Hi I followed the same and also the .lib file created successfully. But when I am trying to use the .lib file in vc++ project and calling the function, I am getting linker error. Can you plz tell me what could be the problem?

  5. 8 Pat October 18, 2011 at 8:08 am

    Thanks for these quick and easy instructions… it worked without much trouble for me. One problem I did run into was that the dll I was interfacing was written in Borland C++. Apparently, the _ prefix convention differs between this and Visual Studio. All the functions in the dll were already prefixed by an underscore, and when creating the lib for Visual Studio (using the above instructions), it then gave them another underscore. This caused my program to fail to link using the lib. I believe that is what they’re referring to in the MSDN article: “The reason for this limitation is based on an assumption made by the LIB utility that all names are automatically exported without a leading underscore. This is only true for _cdecl function names.”

    To fix it, I put an underscore at the beginning of each dll function prototype and calls to the functions in my c++ code (which previously worked when compiled with Borland C++). After doing that, the conventions matched, and everything linked properly. I probably could have tried following the “Stubbing Out Functions” instructions, but this worked with minimal effort, so I’m not gonna mess w/ it. 🙂 You can’t just remove the _ from the function names in the def file, since the dll won’t find the functions without the _.

    Hope this helps in case anyone runs into a similar problem.


  6. 9 Stefan February 13, 2012 at 12:33 pm

    Thank you. Great blog…


  7. 10 Herbert Stocker April 19, 2012 at 9:20 am

    If you cannot use dumpbin, e.g. because it crashes, like in my case, then you can use Dependency Walker for getting the symbol names:
    1.) drop your DLL into Depnedency Walker (it may help to use 32 bit Dependency Walker for 32 bit DLLs and 64 bit DepWalker for 64 bit DLLs.)
    2.) Click the pane with the export names.
    3.) Press Ctrl+A Ctrl+C or do right-click -> Select All, right-click -> Copy Function Names
    4.) paste them into your .def file and add the word EXPORTS on the top.

  8. 11 Jeff Ryan April 20, 2012 at 9:53 pm

    Thanks for the post. Saved my day.

    Just to help future readers, lib /MACHINE: is another option that can possibly help resolve symbol mismatches when you are using 32bit and 64bit builds.

  9. 12 raghunath April 21, 2012 at 10:03 am

    please send me how teate a dll in c

  10. 13 Cormac Phelan July 4, 2012 at 6:23 pm

    Excellent post, very useful

  11. 14 Sander September 28, 2012 at 1:43 pm

    Note that this does not work if functions are declared with __stdcall because the names are mangled then. You can then either change the calling convention (to __cdecl), manually mangle the names in the .def file (append @ where you can get from the linker errors) or create the .lib by using the stub method in the msdn article.

  12. 17 Alain October 2, 2012 at 10:17 am

    Hi! I just created the lib from my dll, but I have a doubt. Since my dll was 5MB and the lib is 4Kb I think that I have to use the dll together with the lib. Is it true?

    thank you for your post!

  13. 20 sparrow October 6, 2012 at 7:22 am

    I have followed your tutorial directly, but when I tried to create *.lib from *.def file, I got LNK1107 error invalid or corrupt file. Cannot read at 0x93E. I checked my def with hexeditor tool and it turns out that there is no char at this index – the last char is indexed under 0x93D. Have anyone experienced such problem?

    • 21 timoncze October 13, 2012 at 12:35 am

      It means that something is wrong in your DEF file. It read the whole thing, but is probably expecting something more (or less). Analyze it and try to fix it.

  14. 22 zibri October 13, 2012 at 9:48 pm

    It would be great to have an automated way to do the opposite…
    I have a .lib and a .h and I with to create a dll with all functions in the .lib.
    Since the lib is HUGE to write a wrapper would be a hard work.
    Also, I need to do this to use the DLL from managed code (vb net) using dllimport. Any clues?

  15. 23 Phyllis December 5, 2012 at 5:34 pm

    Fantastic goods from you, man. I have understand your stuff previous to and you’re just too wonderful. I really like what you’ve acquired
    here, really like what you’re saying and the way in which you say it. You make it entertaining and you still take care of to keep it wise. I cant wait to read far more from you. This is actually a wonderful website.

  16. 24 wordpress hosting January 9, 2014 at 9:30 pm

    Everything is very open with a precise description of the challenges.
    It was truly informative. Your site is extremely helpful.
    Many thanks for sharing!

  17. 25 mitzvah February 11, 2014 at 7:28 pm

    Hello, I do think your website could possibly be having web browser compatibility problems.
    Whenever I take a look at your blog in Safari, it looks fine however, if opening in I.E., it has some overlapping issues.
    I just wanted to provide you with a quick heads up!
    Besides that, wonderful website!

  18. 26 xbox repai February 25, 2014 at 9:49 pm

    I’ve learn some just right stuff here. Definitely price
    bookmarking for revisiting. I surprise how a lot attempt
    you put to create this kind of fantastic informative website.

  19. 27 top web hosting April 14, 2014 at 4:48 pm

    I am not sure where you’re getting your info, but good topic.
    I needs to spend some time learning much more or understanding more.
    Thanks for magnificent information I was looking for this information for my

  20. 28 health and fitness videos June 24, 2014 at 10:44 pm

    My developer is trying to convince me to move to .net from PHP.
    I have always disliked the idea because of the expenses.
    But he’s tryiong none the less. I’ve been using Movable-type on a number of
    websites for about a year and am concerned about switching to another platform.
    I have heard very good things about
    Is there a way I can import all my wordpress posts into it?
    Any kind of help would be greatly appreciated!

  21. 29 Jacquie June 27, 2014 at 6:44 am

    Great work! That is the kind of information that are meant to be shared around the internet.
    Disgrace on Google for not positioning this post upper!
    Come on over and seek advice from my web site . Thank you =)

  22. 30 schtasks.Exe powershell July 7, 2014 at 4:05 am

    Magnificent beat ! I would like to apprentice whilst you amend your web
    site, how could i subscribe for a weblog site? The account aided me a applicable deal.
    I have been tiny bit familiar of this your broadcast provided shiny clear concept

  23. 31 msvcr80.dll missing fix July 31, 2014 at 12:34 pm

    Hello there! This is my first comment here so I just wanted
    to give a quick shout out and say I genuinely enjoy reading through your articles.
    Can you recommend any other blogs/websites/forums that cover the same topics?
    Appreciate it!

  24. 32 jucheck.exe July 31, 2014 at 1:07 pm

    Great blog right here! Additionally your site loads up very fast!
    What host are you using? Can I am getting your affiliate hyperlink for your host?
    I want my site loaded up as fast as yours lol

  25. 33 Roy August 22, 2014 at 12:28 am

    After looking over a number of the articles on your blog, I really like your
    way of blogging. I bookmarked it to my bookmark site list
    and will be checking back soon. Please check out my website too and tell
    me what you think.

  26. 34 UNDERSTANDING WEB HOSTING AND ITS IMPORTANCE September 16, 2014 at 6:10 pm

    After looking over a handful of the articles on your site, I truly appreciate your technique of writing a blog.
    I book marked it to my bookmark site list and will be checking back soon. Please check out my website as well and let
    me know your opinion.

  27. 35 Why Agen Bola is More Than a Betting Website September 20, 2014 at 11:12 am

    Thanks for the good writeup. It if truth be told was a leisure
    account it. Glance complicated to far added agreeable from you!
    However, how could we communicate?

  28. 36 My Website September 21, 2014 at 12:25 am

    Sie sollten unbedingt guten Content verbreiten, der Ihren Lesern einen Mehrwert bietet. Aus diesem Grunde sollten Sie sich auf ein Thema festlegen, mit dem Sie sich auskennen und das Ihnen vor allen Dingen Spaß macht! Mit Affiliate Advertising können Sie sich bequem von zu Hause aus neben dem Hauptjob ein Nebeneinkommen aufbauen. Alles was Sie dazu benötigen ist ein Computer und eine Internetverbindung – und schon kann es losgehen! Dieser Artikel wurde von Laura Geisbüsch als Gastautor geschrieben. Nutzen Sie hier das Kommentarfeld um mir Fragen zu stellen.

  29. 38 digestive disorders September 21, 2014 at 1:29 am

    There’s certainly a lot to know about this issue.
    I like all the points you have made.

  30. 39 September 27, 2014 at 7:27 am

    Hello, everything is going sound here and ofcourse every
    one is sharing facts, that’s in fact excellent, keep up writing.

  31. 40 software September 28, 2014 at 8:00 pm

    Hey there! I’ve been reading your blog for a while now and finally got the courage to go ahead and
    give you a shout out from Porter Texas! Just
    wanted to tell you keep up the good work!

  32. 41 hostnetindia September 29, 2014 at 8:44 pm

    My family always say that I am wasting my time here at web, except I know I am getting know-how daily by reading thes good content.

  33. 42 Matthew R November 20, 2014 at 8:20 pm

    Thank you ! That worked wonderfully ! Your explanation is far better than the rubbish help Microsoft offers. 🙂

  34. 43 Santhi P December 23, 2014 at 9:17 am

    Thanks for the question and answers and you can find more in Name Mangling here in the following blog.

    Name mangling in Cpp with examples

  35. 44 January 8, 2015 at 8:39 pm

    I was very happy to find this site. I want to to thank you
    for your time for this particularly wonderful read!!
    I definitely appreciated every part of it and i also have you saved
    to fav to look at new stuff on your website.

  36. 45 Affiliate Marketing January 10, 2015 at 11:41 am

    It’s impressive that you are getting thoughts from this article as well as from our dialogue made at this place.

  37. 46 Martin M July 14, 2015 at 6:25 pm

    Can you generate header .h file based on dll file?

  38. 47 Wan May 3, 2016 at 11:19 am

    I keep having Entry Point Not Found once i followed all the steps, im really desperate

  39. 48 mangesh July 31, 2016 at 6:59 am

    Please tell me the solution to run it properly.
    For stdcall functions after adding @ in def file built successfully but not fail to run.

  40. 49 Billy Caine January 8, 2017 at 6:09 am

    This is great. I like to use the best 6×9 speakers and subwoofers I can for my vehicle. You get genuinely excellent sound high quality when you merge the two of these types and place them in your auto. Even far better when you use a speaker enclosure.

  41. 50 Heng Zhou April 29, 2017 at 1:59 am

    add /machine:x64 after the lib command.

  42. 51 Whitsundays Tour July 20, 2017 at 2:33 am

    Wow! In the end I got a web site from where
    I be able to in fact get valuable data regarding
    my study and knowledge.

  43. 52 Michael Geary August 31, 2017 at 5:08 am

    Adrian, just FYI, you have a ton of comment spam on this page (and likely on some of your others).

    You can basically assume that every comment that doesn’t say something specific about the actual content of this article is probably spam.

    In any case, thanks for the writeup! As an old-time Windows programmer, I’ve used lib many times, but has been quite a while, so I’d forgotten that it is a nice quick way to generate an import library from a .def file.

  44. 53 hour support October 3, 2017 at 12:51 am

    I visited a lot of website but I conceive this one contains something special in it.

  45. 54 dress up games November 16, 2017 at 10:52 am

    Why visitors still use to read news papers when in this technological globe all is presented on net?

  1. 1 Unresolved external symbol caused by name mangling using Visual Studio 2010 Trackback on February 1, 2012 at 12:02 pm
  2. 2 International customer database Trackback on May 9, 2014 at 5:15 am
  3. 3 Create .lib file from .dll | Thoughts on Programming and Software Trackback on July 10, 2014 at 12:45 pm
  4. 4 professional resume writers in st. louis mo Trackback on November 2, 2014 at 1:37 am
  5. 5 machine a sous fete foraine a vendre Trackback on November 11, 2014 at 1:20 pm
  6. 6 How to generate DLL from existing C++ code using DEF file in Visual Studio 2010 | Ngoding Trackback on November 28, 2014 at 2:05 pm
  7. 7 RTMP C++ client library | 我爱源码网 Trackback on March 2, 2015 at 9:38 pm
  8. 8 How can I use RTMPDump from a Visual Studio C++ project? | 我爱源码网 Trackback on March 2, 2015 at 9:56 pm
  9. 9 Create .lib file from .dll | yuchi's dev Trackback on July 11, 2015 at 3:41 am
  10. 10 me adaraya Trackback on February 6, 2016 at 6:49 am
  11. 11 SDL 2.0.5 and stb_image – Anthony Reddan Trackback on June 7, 2017 at 5:20 am
  12. 12 Miracle box crack latest 2017 download Trackback on October 18, 2017 at 7:58 pm
  13. 13 the sims 2 cd key free Trackback on October 18, 2017 at 9:13 pm
  14. 14 serial key photoshop cs5 1 Trackback on October 18, 2017 at 11:15 pm
  15. 15 it consulting denver Trackback on April 21, 2018 at 1:30 am
  16. 16 เสือมังกร Trackback on July 23, 2018 at 2:59 pm
  17. 17 Sureshot Trackback on July 29, 2018 at 2:37 pm
  18. 18 Shasta Arts Trackback on August 25, 2018 at 1:20 am
  19. 19 indian stocks Trackback on April 23, 2019 at 6:57 am

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: