StaticLib.lib is not a valid win32 application-ERROR

LÊ THÀNH ĐẠT 1 Reputation point

I use Win 10 Visual Studio 2019.This error will be like that: Library/Debug/StaticLib is not a valid Win32 application.
I try many methods on Internet but it's failed.
Please help me, thanks you so much.

A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
2,900 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Viorel 94,761 Reputation points

    If your solution includes several projects, then right-click the main project (which generates the application) in Solution Explorer and select “Set as Startup Project”.

    3 people found this answer helpful.

  2. Jeanine Zhang-MSFT 5,896 Reputation points Microsoft Vendor


    Did you get the error like this?


    As far as I'm concerned, it may build correctly but you're trying to run the .lib like an application. You should 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 in the debug folder.


    And then you could add it to your C++ project:

    1,Add the path to the header file to the Additional Include Directories(property - >c/c++ -> General -> Additional Include Directories)
    2,Add the path to the .lib file to the Additional Library Directories (property -> linker -> General -> Additional Library Directories)
    3,Add the name of the .lib file with its extension to Additional Dependencies (property -> linker -> input -> Additional Dependencies)

    For more details about how to use a static library, I suggest you could refer to the Doc.

    Thank you!