next up previous contents index
Next: Calling XSB from C Up: Foreign Language Interface Previous: Declaration of high level   Contents   Index

Compiling Foreign Modules on Windows and under Cygwin

Due to the complexity of creating makefiles for the different compilers under Windows, XSB doesn't attempt to compile and build DLL's for the Windows foreign modules automatically. However, for almost all typical cases the user should be able to easily adapt the sample makefile for Microsoft VC++:

XSB/examples/XSB_calling_c/MakefileForCreatingDLLs
It is important that the C program will have the following lines near the top of the file:
   #include "xsb_config.h"  
   #ifdef WIN_NT
   #define XSB_DLL
   #endif
   #include "cinterf.h"

Note that these same DLLs will work under Cygwin -- XSB's C interface under Cygwin is like that under Windows rather than Unix.

If the above makefile cannot be adapted, then the user has to create the DLL herself. The process is, roughly, as follows: first, compile the module from within XSB. This will create the XSB-specific object file, and (if using the higher-level C interface) the wrappers. The wrappers are created in a file named xsb_wrap_modulename.c.

Then, create a project, using the compiler of choice, for a dynamically-linked library that exports symbols. In this project, the user must include the source code of the module along with the wrapper created by XSB. This DLL should be linked against the library

XSB\config\x86-pc-windows\bin\xsb.lib
which is distributed with XSB. In VC++, this library should be added as part of the linkage specification. In addition, the following directories for included header files must be specified as part of the preprocessor setup:
    XSB\config\x86-pc-windows
    XSB\prolog_includes
    XSB\emu
In VC++, make sure you check off the ``No precompiled headers'' box as part of the ``Precompiled headers'' specification. All these options are available through the Project»Settings menu item.


next up previous contents index
Next: Calling XSB from C Up: Foreign Language Interface Previous: Declaration of high level   Contents   Index
Luis Fernando P. de Castro 2003-06-27