<i>Wouldn’t the compiler complain that it doesn’t have the definition of the global temp table. </i>
You know the exact format of the GTT since you designed it. If you need the definition for a compiler, then create a temporary version to compile over.
This is no different from any file that must be created dynamically in QTEMP. You create a version in QTEMP and compile interactively, or create a basic CL that controls the format creation and the compile in a single submitted job.