c++ - 错误 LNK2019 : unresolved external symbol _main referenced in function ___tmainCRTStartup and Error 2 error LNK1120: 1 unresolved externals

标签 c++

当我尝试编译我的代码时,我遇到了两个错误。我已经定义了 win32 控制台应用程序。我什至还没有开始编码。我的配置如下 - 链接器 - 子系​​统 - 控制台;链接器 - 高级 - 入口点 - 空白。

       error LNK2019: unresolved external symbol _main referenced in function
        ___tmainCRTStartup 
        Error   2   error LNK1120: 1 unresolved externals   

我不知道发生了什么。以前一切正常,但从今天开始就不行了。您知道我该如何解决吗?

到目前为止我的代码是

 // ConsoleApplication1.cpp : Defines the entry point for the console application.
 //
  #include "stdafx.h"
  #include "tbb/blocked_range.h"
   #include "tbb/tbb.h"
   #include <stdio.h> 
  #include <math.h>
  #include <iostream>
  #include "tbb/parallel_for.h"
  #include <sstream>
  #include <tbb/task_scheduler_init.h>
  using namespace std;
  #define PI 3.14159265
  using namespace tbb;
   // Sequential Execution
  class Sequential
  {
  double * m;
  double *n;
   public:
 Sequential(double n[], double m[]): n(n), m(m){}

void Partition()
{

}

int main(int argc, char** argv)
{

    //double a = 5;
    //double b = 4;
    //Sequential g = Sequential(a,b);
    return 0;
}
 };

谢谢

最佳答案

main 函数必须位于global 命名空间中。 C++ 不是 C#/Java,后者的所有函数都必须在类中。

关于c++ - 错误 LNK2019 : unresolved external symbol _main referenced in function ___tmainCRTStartup and Error 2 error LNK1120: 1 unresolved externals,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23153900/

相关文章:

c++ - 使用 C++ 函数指针作为信号处理程序。

c++ - Do/While 循环不循环

c++ - PostgreSQL 中的性能分析

c++ - VS 2012 模板错误

c++ - 使用 static_assert 检查 Q_OBJECT 宏

c++ - 使用 shared_ptr<string> 到 unordered_set<string>

c++ - 如何修复错误 2298 和 2563

java - Python 与 Java/C 的集成

c++ - 类对象和指针的区别

c++ - 为什么我的右值复制构造函数不起作用?