0

New to c++. I created a new win32 Application project in Visual Studio I selected "Windows application" and "Empty project.

I added a "write.cpp" file under "Source Files" with following code, then I click Build->build solution and got error:

errorLNK2019 and errorLNK1120.

Error 1 error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup U:\CreditFIModels\Models\Risk Premia\SB\IGUpdates\PY\src\c++\writeWin32\writeWin32\MSVCRTD.lib(crtexew.obj) writeWin32

Error 2 error LNK1120: 1 unresolved externals U:\CreditFIModels\Models\Risk Premia\SB\IGUpdates\PY\src\c++\writeWin32\Debug\writeWin32.exe 1 1 writeWin32

I've read threads in SO changed General->Common Language Runtime Support->to either /clr:pure or /clr, it doesn't help. My original setting "No Common Language Runtime Support" doesn't work as well.

Hope anyone can help me figure out what is going on.

// basic file operations
#include <iostream>
#include <fstream>
using namespace std;

int main () {
  ofstream myfile;
  myfile.open ("example.txt");
  myfile << "Writing this to a file.\n";
  myfile.close();
  return 0;
}
Lisa
  • 4,126
  • 12
  • 42
  • 71
  • 1
    Include error message text in a question itself. We can't, possibly, remember all of the compiler / **linker** error codes and their meanings. – Algirdas Preidžius Feb 16 '17 at 00:07
  • If you are compiling native C++ code, the correct option is "No Common Language Runtime Support". The others are for "managed" code. – Bo Persson Feb 16 '17 at 00:11
  • @Bo Persson That was my original setting, and it didn't work. I've updated my post. – Lisa Feb 16 '17 at 00:19
  • Ok, then the next problem is that you should probably have selected "Win32 Console Application" as the project type. – Bo Persson Feb 16 '17 at 00:35

0 Answers0