StaticLib.lib is not a valid win32 application-ERROR

LÊ THÀNH ĐẠT 6 Reputation points
2020-08-11T04:14:16.047+00:00

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.

C++
C++
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.
3,758 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Viorel 118K Reputation points
    2020-08-13T09:21:31.12+00:00

    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”.

    4 people found this answer helpful.

  2. Jeanine Zhang-MSFT 9,771 Reputation points Microsoft Vendor
    2020-08-11T05:33:07.697+00:00

    Hi,

    Did you get the error like this?

    16943-8111.png

    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.

    16893-8112.png

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

    16973-8113.png

    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!


Your answer

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