Making GProlog 1.2.18 on Mac OS X with GCC4

Lindsey Spratt <[email protected]>
Newsgroups gmane.comp.gnu.prolog.general
Message-ID <[email protected]>
  Below are diffs for a simple change to 1.2.18 that will make it build  
and run on Mac OS X using the GCC 4 compiler.

I used a configure command with no optimization specified: when I used  
the default compilation with '-O3', I got the error:

gplc -c --fast-math fd2c.pl

system_error(cannot_catch_throw(error(domain_error('',fx),op/3)))
warning: /home/diaz/GP/src/src/Pl2Wam/read_file.pl:106: system  
directive failed
fatal error: exception raised:  
error(domain_error('',prolog_name),current_prolog_flag/2)
compilation failed

To build:
cd to the directory containing the gprolog to be patched.
Create a file with the patches at the end of this email called  
'diffs-to-patch-18-for-gcc4'.
Apply the patches, cd into /src, and build:

    patch -p1 <../diffs-to-patch-18-for-gcc4

    cd src

    ./autoconf
    ./configure "--with-c-flags=-fomit-frame-pointer"
    make

The build creates a lot of warning messages (which should be cleaned up  
eventually and may be reported as errors on other platforms), but the  
result seems to run OK on Mac OS X.

HTH,
Lindsey Spratt
http://homepage.mac.com/lspratt

==================== PATCHES ================================
diff -Naur  
--exclude-from=/Users/lindsey/Documents/MyDev/CocoaDev/xgp/doc/ 
nonpatch_file_patterns gprolog-1.2.18/src/BipsPl/flag_c.c  
gprolog-1.2.18.gcc4/src/BipsPl/flag_c.c
--- gprolog-1.2.18/src/BipsPl/flag_c.c        2003-01-06  
07:18:08.000000000 -0500
+++ gprolog-1.2.18.gcc4/src/BipsPl/flag_c.c     2006-03-04  
15:11:58.000000000 -0500
@@ -77,7 +77,7 @@
  static int atom_on;
  static int atom_off;
-static int atom_error;
+/* static int atom_error; --GCC4 CHANGE-- */
  static int atom_warning;
  static int atom_fail;
diff -Naur  
--exclude-from=/Users/lindsey/Documents/MyDev/CocoaDev/xgp/doc/ 
nonpatch_file_patterns gprolog-1.2.18/src/BipsPl/os_interf_c.c  
gprolog-1.2.18.gcc4/src/BipsPl/os_interf_c.c
--- gprolog-1.2.18/src/BipsPl/os_interf_c.c  2003-11-03  
05:08:18.000000000 -0500
+++ gprolog-1.2.18.gcc4/src/BipsPl/os_interf_c.c     2006-03-04  
15:13:32.000000000 -0500
@@ -94,8 +94,8 @@
  static int atom_dt;
-static int atom_read;
-static int atom_write;
+/* static int atom_read; --GCC4 CHANGE-- */
+/* static int atom_write; --GCC4 CHANGE-- */
  static int atom_execute;
  static int atom_search;
diff -Naur  
--exclude-from=/Users/lindsey/Documents/MyDev/CocoaDev/xgp/doc/ 
nonpatch_file_patterns gprolog-1.2.18/src/EnginePl/obj_chain.h  
gprolog-1.2.18.gcc4/src/EnginePl/obj_chain.h
--- gprolog-1.2.18/src/EnginePl/obj_chain.h     2004-01-16  
11:01:00.000000000 -0500
+++ gprolog-1.2.18.gcc4/src/EnginePl/obj_chain.h     2006-03-04  
15:14:59.000000000 -0500
@@ -76,7 +76,8 @@
  #ifndef _MSC_VER
-extern ObjChain *obj_chain_stop;
+
+static ObjChain *obj_chain_stop; /* --GCC4 CHANGE-- */
  static ObjChain obj_chain_start =
   { OBJ_CHAIN_MAGIC_1, OBJ_CHAIN_MAGIC_2, &obj_chain_stop, OBJ_INIT };
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.