A compass is any device that points out magnetic north.
One of the easiest ways to construct a compass is place a magnetized piece of metal in a solution so that it floats. Miles O'Brien created a primitive compass while marooned with Benjamin Sisko on a planet in the Orellius system. (DS9: "Paradise")