Linking with QUI

During development of applications involving both Prolog and foreign code, it can be very useful to build a stand-alone program that includes QUI. This way, you can use the QUI debugger for stepping through the Prolog code and a standard debugger such as gdb(1) for stepping through the foreign code.

A good way to do this is to create a file qui.pl containing just the one line:

     :- ensure_loaded(library(qui)).
     

This should then be compiled to QOF in the normal way and linked into your application. For example:

     % qpc -D <application files> qui.pl
     

Then start up the resulting executable file using a command such as

     % gdb a.out
     

See fli-p2f-fcr for information about using a standard debugger in conjunction with a Prolog executable file.

Please note: The reason for putting the ensure_loaded command in a file by itself, rather than including it in your application code, is that it will not work if executed in an ordinary prolog system that does not include QUI; it is not possible to load QUI dynamically.