locked
.lib is not a valid Win32 application - Visual Studio 2017 RRS feed

  • Question

  • My program is not running due to this error which pops up. I tried building and cleaning my solution but it still does work. I am working in visual studio c++ and have created a static link library which I want to link to my <g class="gr_ gr_46 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="46" id="46">cpp</g> file. I have a windows 10 X64 bit computer

    Below is the error

    Unable to start program c:\users\source\repos\NewProject\NewProject.lib c:\users\source\repos\NewProject\NewProject.lib is not a valid Win32 application

    Please Help me it would be great Thank you in advance!

    Tuesday, December 25, 2018 3:32 AM

Answers

  • Hello Brown12345,

    Thanks for posting here.

    Did you get the error like this?

    I think maybe it builds correctly but you're trying to run the .lib like an application. You could right click on the project and select 'Build' like the following show.

    After you finish building the .lib project, you will get a .lib file like this.

    Then add it to your C++ project. two method:  
        1. Configuration Properties->Linker->Input->Additional Dependencies: add your lib file to the list here.
        2. Use an absolute or relative path, or add directory to
                Project Properties->Configuration Properties->C/C++->General->Additional Include Directories.

    Hope this will help you.

    Best Wishes,

    Jack


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    • Edited by Jack Zhang - AAA Tuesday, December 25, 2018 6:19 AM
    • Proposed as answer by Eddie Lotter Wednesday, December 26, 2018 12:21 AM
    • Marked as answer by Brown12345 Wednesday, December 26, 2018 3:28 AM
    Tuesday, December 25, 2018 6:08 AM

All replies

  • Hello Brown12345,

    Thanks for posting here.

    Did you get the error like this?

    I think maybe it builds correctly but you're trying to run the .lib like an application. You could right click on the project and select 'Build' like the following show.

    After you finish building the .lib project, you will get a .lib file like this.

    Then add it to your C++ project. two method:  
        1. Configuration Properties->Linker->Input->Additional Dependencies: add your lib file to the list here.
        2. Use an absolute or relative path, or add directory to
                Project Properties->Configuration Properties->C/C++->General->Additional Include Directories.

    Hope this will help you.

    Best Wishes,

    Jack


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    • Edited by Jack Zhang - AAA Tuesday, December 25, 2018 6:19 AM
    • Proposed as answer by Eddie Lotter Wednesday, December 26, 2018 12:21 AM
    • Marked as answer by Brown12345 Wednesday, December 26, 2018 3:28 AM
    Tuesday, December 25, 2018 6:08 AM
  • Thank You So Much !!!!!!!!! 😁 

    It works 

    Wednesday, December 26, 2018 3:29 AM
  • I did this and then pressed the local windows debugger button .Still the same error.

    Friday, August 28, 2020 10:44 AM
  • I did this and then pressed the local windows debugger button.Still same error.
    Friday, August 28, 2020 10:44 AM
  • I did this and then pressed the local windows debugger button.Still same error.

    What do you mean by "I did this..."?

    A library (.lib) cannot be run under the Visual Studio Debugger.  It must be linked into an executable program (.exe).  The executable program can be started under the debugger.

    So start a new thread to show us exactly your own situation.

    You should ask your C++ questions in https://docs.microsoft.com/en-us/answers/topics/c++.html since this forum will soon be fully migrated and closed to future activity.


    • Edited by RLWA32 Friday, August 28, 2020 11:40 AM
    Friday, August 28, 2020 10:57 AM