Build Succeeded, but no .lib file gets created

前端 未结 10 1288
执笔经年
执笔经年 2021-01-31 13:37

I inherited a substantial amount of code, including a visual studio project that is supposed to (as best as I can tell) build a .lib file. Visual studio says \"... Generating C

相关标签:
10条回答
  • 2021-01-31 14:09

    Open the Project Properties (right-click the project in Solution Explorer, select 'Properties'). Under 'Librarian', check 'Output File' - that's where the output should go.

    If this looks right, try dir /s *.lib in a suitable subdirectory for your project, to see if you can locate the output library by date and time. If you still can't find it, try a clean rebuild (right click project, select 'Rebuild').

    For DLLs, a .Lib file is not created if the DLL exports nothing for external usage. I don't think this applies for static lib builds but I would make sure you are exporting something public from your library project source code.

    0 讨论(0)
  • 2021-01-31 14:15

    I just ran across this problem as well.

    It was due to using an invalid macro in the output directory definition. In my case, it was

    when it should have been

    I had to blank out the full path in the second screen shot. I had an incorrect macro. I was using MsBuildProjectDir when I should have been using MsBuildProjectDirectory. The read-only text box will show the full path (eg: C:\Development\blah\blah\blah\) when the output directory is valid. If the output directory is not valid, you'll get something like the first screenshot.

    0 讨论(0)
  • 2021-01-31 14:17

    My static library contains nothing but two template classes, so I didn't have a .cpp file. This caused Visual Studio 2015 to not output a .lib file. To solve this, I made a file huh.cpp which includes all of the headers.

    0 讨论(0)
  • 2021-01-31 14:19

    If the Methods you want to export are in a class, you have to __declspec(dllexport) on the class. Otherwise no .lib will be created.

    0 讨论(0)
  • 2021-01-31 14:20

    .lib will not get generated if you miss to add prefix __declspec(dllexport) for methods.

    0 讨论(0)
  • 2021-01-31 14:20

    In the DLL project, put __declspec(dllexport) beginnings of methods defined in .h and .cpp files.

    After all, compile your dll again, so .lib file will be generated and ready for linking.

    put Class Foo
    {
    public:
        __declspec(dllexport) int GetFoo() const;
    
    0 讨论(0)
提交回复
热议问题