0

I am getting the two errors when I try to compile my code. I have defined win32 consile application. I have not even yet started coding. My configurations are the following - Linker - subsytem - Console; Linker - Advanced - Entry Point - Blank.

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

I don't know what happened. Before everything was working fine but from today it does not. Do you have any idea how I can resolve it that?

My code so far is

 // 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;
}
 };

Thanks

user3017335
  • 285
  • 4
  • 14
  • The `main` issue has been resolved, but in addition, some help with the code – Cheers and hth. - Alf Apr 18 '14 at 12:19
  • First, to avoid non-standard preprocessor behavior, remove "precompiled headers" in the projects settings, and remove the `` include – Cheers and hth. - Alf Apr 18 '14 at 12:19
  • 1
    Second, instead of ``, which is not type safe i/o, use C++ ``. Otherwise, as beginner, you will run into nasty issues where a variable or value of one type is erroneously interpreted as being of some other type. – Cheers and hth. - Alf Apr 18 '14 at 12:21
  • 1
    Third, instead of using `#define` to define a constant (pi in this case), just **define a constant**. Use the `const` keyword. That's what it's for. Macros don't respect scopes. With macros you will run into very annoying inadvertent text substitutions and name collisons. – Cheers and hth. - Alf Apr 18 '14 at 12:21
  • 1
    Fourth, instead of raw arrays and explicit dynamic allocation, like `double* n`, use `std::vector`. I.e. `std::vector n`. Unless you like wasting time on memory management subtleties like the rule of 3, and so on. – Cheers and hth. - Alf Apr 18 '14 at 12:23
  • Fifth, code formatting. Visual Studio (which you're evidently using) can format the code for you. There are also free formatters available on the net, such as AStyle. It's a good idea to format the code properly before posting it to SO or other forum. Experienced programmers are misled by inconsistencies in formatting. – Cheers and hth. - Alf Apr 18 '14 at 12:26
  • To me it seems you want to do some pretty advanced things (indicated by your headers) before really knowing the language you use. Learn to use C++ that way it's supposed to be used. Learn to walk before you learn to run and all that. I suggest you check [The Definitive C++ Book Guide and List](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list), and also [a good reference site](http://en.cppreference.com/w/cpp). – Some programmer dude Apr 18 '14 at 12:29

1 Answers1

4

The main function must be in the global namespace. C++ is not C#/Java where all functions must be inside classes.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621