users-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

MSVC build of gprolog 1.2.1


From: Gerald W. Shapiro
Subject: MSVC build of gprolog 1.2.1
Date: Thu, 11 Oct 2001 11:44:20 -0400 (EDT)

0. Preamble

A. What is this document?
        This document contains information about building gprolog-1.2.1
using the MSVC++ compiler in a Microsoft Windows environment. The document
provides details not in the existing documentation, and changes required
to the 1.2.1 source distribution to have a successful build.
        The target audience is a user familiar with the Microsoft Windows
OS, but not necessarily with Unix.

B. Who wrote this document?
        Gerald Shapiro, address@hidden . I have some familiarity with
Unix, more with Microsoft Windows, but in both cases primarily as a user,
not a developer.

C. Why did he write this?
        gprolog is distributed as a set of (plain text) source code files,
with associated (plain-text) files for directing the compilation
process(make files, configuration script). Pre-compiled binaries are *not*
distributed. You have to build the executable on your machine. The build
environment is Unix-oriented. You will need to install some (free)
software to create the proper environment for building gprolog.
        I was able to build gprolog using gcc (the default c compiler) in
the Cygwin environment, but my compiled program using fd variables seems
to write into memory used by other windows apps. As a result, I would get
OS errors, and was unable to shut down in an orderly fashion. I decided to
build using the MSVC option, and see if the problems were eliminated.
        Along the way, I had to figure out a few things, and I hope that
this will help others in a similar situation.

D. Caveats
        This is how I got things to work, using Win95. Doubtless there are
other ways to get to the same result. Other windows installations may
exhibit different behavior. Let me know if I can improve this document in
some way.



I. Modifications to the gprolog-1.2.1 source files
        Any text editor will work.      

1. Delete the definition of stat in src\EnginePl\arch_dep.h
(It is already defined in an MSVC header)

2. Line 154 of cpp_headers.c add a do-nothing line after #endif (I added i=0 ; )
to stop msvc from complaining about a missing semi-colon.

3. In src/EnginePl/Makefile.in replace $(ROOT_DIR)/src/$$i with ../$$i
    (windows has trouble with the full cygwin path, but relative paths are ok)

4. In src/Fd2c/compile.pl , line 511, change reg_alloc to reg_alloc.pl



II. Creating the build environment

A. Cygwin
        The Cygwin packages provide a Unix-like environment on windows
machines. Installation is via the Internet. See www.cygwin.com
        When you install Cygwin, you will need to install a number of
packages containing software used in the build process. I am fairly
certain that you will need the following (some of these may be
superfluous, but having them around won't hurt):

        ash, bash, binutils, bzip2, gzip, make, sed, sh-utils, tar, unzip, zip, 
zlib

If, during the build, you get a message complaining about something
missing, please note that I also had the following packages in my Cygwin
installation, and maybe one or more of these is needed for the build:

        cpio, file, fileutils, findutils, gawk, grep, readline, regex,
termcap, textutils, time

If you really want a Unix-like environment, there are other packages that
are useful to indispensable, but I do not think that they are needed if
all you want to do is build gprolog.


B. NASM
        This is a win32 assembler. Place the executable in a directory
that is in your path. You can find it at
www.web-sites.co.uk/nasm/where.html
        Keep the assembler around after the install; you will need it to
compile gprolog source code.


C. MSVC++ environment variables
        The MSVC environment variables can be set by running the file
vcvars32.bat which comes with MSVC++. *This must be done before entering
the Cygwin environment.* Running vcvars32.bat from the bash prompt will
not set the environment properly. Either
        1. Open a DOS window. Run vcvars32.bat from a dos prompt, then run
cygwin.bat in the same DOS session, or
        2. Have the MSVC++ settings from vcvars32.bat set in your autoexec.bat

D. Building the package
        Once you have modified the source files and set up the build
environment, follow the instructions in the file INSTALL in the gprolog
distribution. Bonne chance!



III. Running the Gnu Prolog executables
        Cygwin is not required to run the executables; they are native
win32 programs. Depending upon the option you selected during the build,
the top-level may run in a window. The prolog compiler, gplc, runs from a
dos prompt.

A. Runtime environment for gplc
        When you compile programs using gplc, you will need to have the
environment variables for MSVC in place. Either run vcvars32.bat from the
dos prompt before running gplc, or have the MSVC variables in your
autoexec.bat.

B. Differences in win32 behavior and standard gprolog behavior
        1. See the file PROBLEMS for information about things that won't work.

        2. In consult/1 predicates, you will need to give the full
filename+extension, enclosed in single quotes; i.e.
        consult(foo)
will throw an error
        consult('foo.pl')
will read the contents of foo.pl into the fact-base.

        3. If consult/1 still throws an error, try giving the full DOS
path. Be sure to escape the slashes by doubling them, e.g.
                consult('C:\\mydata\\thisdata\\foo.pl')

****** END *******




reply via email to

[Prev in Thread] Current Thread [Next in Thread]