Visual Studio 2026 not building .lib file in dll project

Sahil Dash 0 Reputation points
2025-12-11T03:40:46.39+00:00

Hello! As the title states, I have set up a vs dll project, but when i build the project, only a dll file is generated; there is no .exp or .lib files. I have gone online to find a fix for this, but all of the fixes included something I already did, like adding the (proj name)_EXPORTS preprocesser definition and the __dllspec(dllexport) and import macro, so I hope you guys can help me. This is the first time i've asked a question on this sort forum, so i dont know exactly how much information to give, but basically, my dll project builds into a dll and lib file which is then used by another project in the same solution (and so the other project can't build because there is no .lib file). If you need any other info to help me, like source code screenshots or anything else, just tell me, as I wish to go back to working on my project asap. Thanks!

Developer technologies | Visual Studio | Setup
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Viorel 125.7K Reputation points
    2025-12-11T04:45:56.4666667+00:00

    Try this setup: go to New Project, select C++, Windows Desktop Wizard, enter name and press Create. Then select Dynamic Link Library (dll), select Export Symbols.

    The compiled files will include .dll, .lib, .exp. If it works, then add your functions, remove the samples.


  2. Adiba Khan 1,520 Reputation points Microsoft External Staff
    2025-12-11T07:45:51.46+00:00

    Thanks for reaching out. This normally occurs then the project is missing export definitions on certain configuration settings.

    1. Ensure At least one function/class is exported from the DLL the import library(.llb) is only generated if exported symbols exist in your DLL make sure your header uses __declspec(dllexport)
         #ifdef MYDLL_EXPORTS
         #define MYDLL_API __declspec(dllexport)
         #else
         #define MYDLL_API __declspec(dllimport)
         #endif
         MYDLL_API void MyFunction();
      
      Then Define MYDLL_EXPORTS in the project settings: Project properties -> C/C++ -> Preprocessor -> Preprocessor Definitions -> add:
         MYDLL_EXPORTS
      
      If no exports exist, Visual Studio will not generate a .llb file.
    2. Verify the project type Ensure you created: Project Type: Dynamic link library(DLL) Not:     
      1. Empty project
      2. Static Library
      3.  Console App
      Check: Project -> Properties -> General -> Configuration Type = Dynamic Library (.dll)
    3. Check if the .llb file output path is correct Go to: Project properties -> Linker -> General ->Output file And Project Properties -> Linker -> General -> Import Library The default import library path is:
         $(OutDir)$(ProjectName).lib
      
      If the import library field is empty, add the above value.
    4. Check for “No import library” setting Go to: Linker -> Advanced -> No import library Ensure it is set to:
         No
      
      If set to yes, the .llb will never be generated
    5. Clean and rebuild Try: Build-> Clean solution Build-> Rebuild solution

    Additional notes

    • Visual Studio generates .exp and .lib files only when you export at least one symbol
    • If you are using module (.def) files. Ensure exports are correctly defined.

    Please let us know if you require any further assistance we’re happy to help. If you found this information useful, kindly mark this as "Accept Answer".

     

     


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.