Almost succesfull build on AIX

Thomas Vogels Thomas Vogels <>
Fri, 09 Jul 1999 21:53:28 -0400

These are some notes about compilation of R-devel (1999-July-08):

-- Compilation breaks when using gcc due to a bug in the include
files.  gcc is version 2.8.1.  In the files Defn.h, Rsock.c and
sock.c, I had to add "typedef long blkcnt_t" which somehow is not
found in sys/types.h.  This may be specific to my installation or to
this version of gcc.

-- The linking stage breaks because it can't find libz.a and
libncurses.a.  I can't quite figure out why R.X11 would want them.
This appears to be a new feature in configure.  BTW, for the readline 
lib I need -lcurses (note no n).

-- Sorry, I forgot to pass this on: You (Kurt) should try to link with
ld not with gcc.  (This will cover up that I have no clue why -L<path>
wouldn't pick up libgcc.a.)  So the DLLFLAGS should contain -L<path>
-lgcc where path is taken from "gcc --print-libgcc-file-name"

Here is the deal with LDCMD/SHLIBLD as far as I understand it:

-- For the R binary (R.X11) we need:
   == LDCMD: ld (native linker)
   == DLLFLAGS: mainly the export symbol flags
	("-bdynamic -bE:${EXPORTFILE} -bM:SRE") and libraries ("-lc -lm
	-l<fortran libs>", if CC==gcc libgcc.a as well);
	but also the LDFLAGS (see buttom).

-- For shared libraries (like we need:
   == SHLIBLD:  ld
   == SHLIBLDFLAGS: again the symbol stuff
	("-bM:SRE -bnoentry -bexpall -bI:${EXPORTFILE}"), maybe libraries

Below is some code that can figure out which libraries to use and
where they are.  "ld -bnobind" does the work, providing us wiht lines
like "i array.o" or "lib /usr/lib/libm.a".  This code would put all
symbols that are in R.X11 (not just all the .o and .a files) into the
export file.  Advantage:  If the shared libs don't need any more
libraries than R, we are set and don't need any libraries (-lm etc) in
SHLIBLDFLAGS.  Disadvantage:  We have to make sure that everything
from the libraries actually makes it into R.  Dunno.

-- warning shell script ahead, avert eyes --
ld -bnobind "$@" |
sed -n -e 's/^i /. /p' -e 's/^lib \(.*\)/\1 \1/p' |
        while read a b; do
                echo 1>&2 "$a $b"
                echo "#! $a" >> $mainexp
                $nm $nmopts $b |
                        awk '
$2 == "T" && $1 ~ /^\.[^_]/ { found[substr($1, 2)] = 1 }
$2 == "D" { text[$1] = 1 }
$2 == "B" && $1 ~ /^[^_]/ { bss[$1] = 1 }
        for (x in text)
                if (found[x]) print x;
        for (b in bss)
                print b;
}' |
                        sort | uniq >> $mainexp
-- you may now open your eyes again --

My suggestion would be: - fix ldAIX so that it helps finding all the
libs and we can use ld as the linker command.  (I can do this).  -
leave the libs in SHLIBLDFLAGS.  This makes the shared libs a little
bit bigger but we are on the save side.

This is new but may help:  If I want to have my local copy of
readline linked into R, I have to set in my

I can't put the path to my libreadline.a into LIBS, this would fail.
I need a seperate way of telling to the linker where to find local
libs, which is what LDFLAGS is meant for.  BUT DLLFLAGS does currently
not include the LDFLAGS.

It's still compiling the docs.  make check will have to wait till tomorrow.


-- (Tom Vogels)   Tel: (412) 268-6638   FAX: -3204

r-devel mailing list -- Read
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: