简体   繁体   English

.lib 不是有效的 Win32 应用程序 - Visual Studio 2015

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

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.我正在尝试在 C++ 中创建一个简单的 .lib 文件,以尝试使用 C++/CLI 包装技术在我的 C# 中使用代码。 The problem is, my C++ code in itself isn't compiling successfully.问题是,我的 C++ 代码本身没有成功编译。 It keeps pushing the 'not a valid Win32 application' error.它不断推送“不是有效的 Win32 应用程序”错误。 I tried looking up the same problem and many answers suggested there were .NET framework issues with Windows XP.我尝试查找相同的问题,许多答案表明 Windows XP 存在 .NET 框架问题。 But I am running it on 'Visual Studio 2015 (v140)' Platform Toolset.但我在“Visual Studio 2015 (v140)”平台工具集上运行它。 My Desktop is a 64bit OS (x64 processor)running Windows 10 pro.我的桌面是运行 Windows 10 专业版的 64 位操作系统(x64 处理器)。

Here's a snippet of my Project Properties:这是我的项目属性的片段:

下面是我的头文件代码:

 #pragma once

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

And this is my .cpp code :这是我的 .cpp 代码:

     #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!您的帮助将不胜感激!

I'm guessing it builds correctly but you're trying to run the .lib like an application.我猜它构建正确,但您正在尝试像应用程序一样运行 .lib。 Right click on the project and select 'Build'右键单击项目并选择“构建”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM