You can set modes on the commandline using -S<x> parameters, or in source with $Mode.
If you rely on the commandline, or the IDE to do so in the commandline, you need to pass appropriate parameters in other cases too.
Or use {$mode delphi} or {$mode objfpc} systematically.