r1 - 04 Jun 2002 - 09:10:15 - JanWielemakerYou are here: TWiki >  Foreign Web  > BorlandC

Using SWI-Prolog with Borland C on WIndows

The default SWI-Prolog binary for Windows is compiled using MicroSoft Visual C version 5. Gerhard Wolfstieg has described how the DLL can be used with Borland. He described this for embedding SWI-Prolog, but most likely you can follow the same lines to create DLLs to be used by SWI-Prolog. Here is the story:

  • Type in a DOS-box (or into a batch file):

<implib.exe-path>\implib <desired-path>\libpl.lib <SWI-directoy>\bin\libpl.dll

example (for my machine):

d:\bc5\bin\implib d:\bc5\lib\libpl.lib d:\SWI\bin\libpl.dll

  • Add the created libpl.lib to your project. Ensure that you have turned on the multi thread switch in the target expert (-> context menu for your executable in the project window)

You need this for embedding on Windows regardless of Borland C

  • Append the line PATH=<SWI-Home-directory>\bin;%PATH% in the autoexec.bat (for NT/2000/XP you can set environment variables from the Control Panel).

  • When embedding, make sure the environment variable %SWI_HOME_DIR% points to the installation directory of Prolog. See above for setting variables. You can also use the following before calling PL_initialise( argc, argv );

putenv( "SWI_HOME_DIR=D:\\SWI" );

The steps below are integrated into the main source for 5.0.7

  • Unless SWI-Prolog.h is adapted to BC needs: either set for the project: local options/32-Bit Compiler/Calling conventions to "standard" or: you have to modify function declarations for each dll-inport like #define SWI_IMPORT _stdcall on top of the header file <return_type> _stdcall <funktions_name>( arg... ); /* everywhere needed - controllable by the linker errors */

  • insert the code below on top of source files where needed (e.g. before including SWI-CPP.h).

#if defined( BORLANDC ) #define __inline inline #endif

-- JanWielemaker - 04 Jun 2002

Edit | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r1 | More topic actions
 
Powered by TWiki
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback