Visual Express 2012 C++ error LNK2001
Visual Express 2012 C++ error LNK2001
我知道这是一个常见的错误。我已经试着解决这个问题一个星期了。我正在使用Visual Express 2012和c++编码。我开始一个新的,但空的,win32应用程序。然后向项目添加一个UI表单。在解决方案中有一个头文件和我正在使用的cpp文件。当我尝试编译时,我得到一个错误LNK2001和LNK1120。
错误1错误LNK2001:未解析的外部符号__tWinMain c: users me desktop visual c++ workspacewinFormExp01LINK winFormExp01
错误2错误LNK1120: 1 unresolved外部c: users me desktop visual c++工作区 winFormExp01 调试 winFormExp01.exe winFormExp01
头文件:
#pragma once
namespace winFormExp01 {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Summary for MyForm
/// </summary>
public ref class MyForm : public System::Windows::Forms::Form
{
public:
MyForm(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~MyForm()
{
if (components)
{
delete components;
}
}
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->SuspendLayout();
//
// MyForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(284, 262);
this->Name = L"MyForm";
this->Text = L"MyForm";
this->Load += gcnew System::EventHandler(this, &MyForm::MyForm_Load);
this->ResumeLayout(false);
}
#pragma endregion
private: System::Void MyForm_Load(System::Object^ sender, System::EventArgs^ e) {
}
};
}
cpp文件:
#include "MyForm.h"
using namespace System;
using namespace System::Windows::Forms;
[STAThread]
int Main(array<String^>^ args)
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
winFormExp01::MyForm form;
Application::Run(%form);
return 0;
}
我试图得到一个基本的windows应用程序运行与尽可能少的脂肪。非常感谢所有的帮助。谢谢!
你必须使用WinMain而不是main。
我不确定WinMain应该是什么样子,但是如果你从模板中创建一个新的"Windows应用程序",或者"Windows窗体"项目,希望其中一个会有它,你可以复制WinMain函数减速。
你可以试试这个吗?
void __stdcall WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
long lpCmdLine,
int nCmdShow)
起始地址是C运行时库中的函数名。链接器根据程序的属性选择它。
mainCRTStartup (or wmainCRTStartup) An application using /SUBSYSTEM:CONSOLE;
calls main (or wmain)
WinMainCRTStartup (or wWinMainCRTStartup) An application using /SUBSYSTEM:WINDOWS;
calls WinMain (or wWinMain), which must be defined with __stdcall
那么,链接器在你的程序中寻找WinMain,但是它找不到并且抱怨
相关文章:
- "error: no matching function for call to"构造函数错误
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 使用 LuaBridge 将 LuaJIT 绑定到C++会导致"PANIC: unprotected error"
- OpenMP卸载说'fatal error: could not find accel/nvptx-none/mkoffload'
- C++错误:"error: int aaa::bbb is protected within this context"
- 尝试链接我的着色器时,我收到错误代码"error c5145 must write to gl_position"
- C++,在int数组中输入字符串或字符会输出0,而不是ascii或error
- 使用 cmake 的 LLVM 构建在 tsan_libdispatch_mac.cc 期间失败; "Error: conflicting types for ..."
- C++ "error: invalid use of void expression"
- struct.error:解压缩 C++ 结构时,解包需要 288 字节的缓冲区
- ERROR LNK2001 AND LNK2019
- "Error LNK2001: unresolved external symbol _main"仍然存在
- C++ OOP LNK2001 ERROR
- 我收到错误"LINK : error LNK2001: unresolved external symbol _WinMainCRTStartup"
- C++ - LNK2001 error
- Visual Express 2012 C++ error LNK2001
- 将 Antlr 与 Visual Studio 集成时出现问题 C++ 2010 的 "error LNK2001: unresolved external symbol"
- error lnk2001: closedir, readdir, opendir
- error LNK2001 Visual C++
- 从 Visual Studio 2012 使用 GnuTLS 3.1.6 时获取"error LNK2001: unresolved external symbol _gnutls_free"