Try to add the {$APPTYPE CONSOLE} directive at the top of your programs source. This will make the program compile as a console program as Lazarus by default assumes programs are GUI. Or go to Project > Project Options > Linking and untick checkbox next to "win32 gui application" or similar.

You can get a better description of the APPTYPE directive here.