- <para>Some packages depend on other packages, for example the
- <literal>text</literal> package makes use of some of the modules
- in the <literal>lang</literal> package. The package system
- takes care of all these dependencies, so that when you say
- <literal>-package text</literal> on the command line, you
- automatically get <literal>-package lang</literal> too.</para>
+ <para>There's one case where you need to use the
+ <option>-package</option> option even for auto packages: when
+ linking a program in batch mode mode (<xref linkend="options-order"/>)
+ <footnote><para>This is because
+ GHC can't figure out from the object files which packages are
+ required; in <option>––make</option> mode and in
+ GHCi the compiler has more information available to figure out
+ the package dependencies. We might try to lift this restriction
+ in the future.</para></footnote>. For example, to link a
+ program consisting of objects <filename>Foo.o</filename> and
+ <filename>Main.o</filename>, where we made use of the
+ <literal>network</literal> package, we need to give GHC the <literal>-package</literal> flag thus:
+
+<screen>$ ghc -o myprog Foo.o Main.o -package network</screen>
+
+ The same flag is necessary even if we compiled the modules from source, because GHC still
+ reckons it's in batch mode:
+<screen>$ ghc -o myprog Foo.hs Main.hs -package network</screen>
+In <literal>--make</literal> and <literal>--interactive</literal> modes (<xref linkend="modes"/>), however, GHC figures out
+the auto packages required for linking without further assistance.
+</para>
+