.lib is not a valid Win32 application - Visual Studio 2015

Shai picture Shai · May 16, 2017 · Viewed 13k times · Source

I am trying to create a simple .lib file in C++ to try and use the code in my C# using C++/CLI wrapping techniques. The problem is, my C++ code in itself isn't compiling successfully. It keeps pushing the 'not a valid Win32 application' error. I tried looking up the same problem and many answers suggested there were .NET framework issues with Windows XP. But I am running it on 'Visual Studio 2015 (v140)' Platform Toolset. My Desktop is a 64bit OS (x64 processor)running Windows 10 pro.

Here's a snippet of my Project Properties:

Below is my header file code:

 #pragma once

 namespace AddTwoNumbersLib
 {
    class AddClass
    {
        public:
        static double Add(double x, double y);
    };
}

And this is my .cpp code :

     #include "AddClass.h"

     namespace AddTwoNumbersLib
 {
        double AddClass::Add(double x, double y)
         {
              return x + y;
        }
}

I'm struggling with this since I'm an amateur. Your help would be greatly appreciated!

Answer

vermooster picture vermooster · May 16, 2017

I'm guessing it builds correctly but you're trying to run the .lib like an application. Right click on the project and select 'Build'