I'm writing a simple transpiler in C++ that takes Brainfuck code and converts it into C++. It's then supposed to compile it with G++ with the following code:
std::string compileCommand{ "g++ file.cpp -o file" };
system(compileCommand.c_str());
But when I run the program, G++ produces this error:
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libmingw32.a(main.o):(.text.startup+0xa0): undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status
However, when I run...
g++ file.cpp -o file
...from outside the program, it compiles just fine. Why is this happening and how can I fix it?
file.cpp:
#include <iostream>
#include <stdio.h>
int main(int argc, char *argv[])
{
char *ptr = new char[30000]{ 0 };
++*ptr;
++*ptr;
putchar(*ptr)
}