2

I am trying to compile a program from 1988. This program computes two-dimensional reconstructions from computerized-tomography-type experiments - only it takes into account first order diffraction of light. I uploaded the archive there:

http://ubuntuone.com/1LXF5SBtUToJZ2lSgGJS47

It contains three folders:

Lib  - libraries
Man  - manuals on the programs
Src  - the actual source scripts

The Src and Lib both contains a Makefile. When I try to compile, I get:

/Src$ make
ncc david.c -g  -o david libuis.a -lm 
make: ncc: Command not found
make: *** [david] Error 127

[EDIT] As suggested by alexandernst I installed nescc and replaced ncc with nescc in the Makefile.

The file libuis is located in Lib. When I try to compile that:

/Lib$ make
make: `libuis' is up to date.

[EDIT] As suggested by greghnz, I copied Lib/libuis to Src/libuis.a.

[EDIT] As suggested by Evert, I symlinked Lib/diffract.h to Src/diffract.h and the compilation went further.

When I now try to compile, I get:

nescc david.c -g  -o david libuis.a -lm 
In file included from david.c:1:0:
diffract.h:41:57: warning: conflicting types for built-in function ‘csqrt’ [enabled by default]
diffract.h:42:43: warning: conflicting types for built-in function ‘cexp’ [enabled by default]
david.c: In function ‘main’:
david.c:93:5: warning: incompatible implicit declaration of built-in function ‘exit’ [enabled by default]
david.c:177:4: warning: incompatible implicit declaration of built-in function ‘exit’ [enabled by default]
david.c:200:8: warning: extra tokens at end of #endif directive [enabled by default]
david.c:400:8: warning: extra tokens at end of #endif directive [enabled by default]
david.c: In function ‘syntax’:
david.c:466:2: warning: incompatible implicit declaration of built-in function ‘exit’ [enabled by default]
libuis.a: could not read symbols: Archive has no index; run ranlib to add one
collect2: error: ld returned 1 exit status
make: *** [david] Error 1

I ran (I have no idea what that does)

ranlib libuis.a

and nothing was returned. When I rename the Lib/libuis and try to compile it, I get this:

nescc -c -g  FFTUnpack.c UnWrap.c UnWrap2d.c cfft.c cfft2d.c chamming.c cmodulate.c comm.c complex.c ctranspose.c debug.c ellipse.c fft.c fft2d.c findpoint.c findray.c findscat.c fmax.c fmin.c hamming.c mode.c modulate.c numout.c picout.c syntax.c transpose.c Green.c
In file included from UnWrap.c:14:0:
diffract.h:41:57: warning: conflicting types for built-in function ‘csqrt’ [enabled by default]
diffract.h:42:43: warning: conflicting types for built-in function ‘cexp’ [enabled by default]
UnWrap.c: In function ‘UnWrap’:
UnWrap.c:88:3: warning: incompatible implicit declaration of built-in function ‘exit’ [enabled by default]
UnWrap.c:147:8: warning: extra tokens at end of #endif directive [enabled by default]
UnWrap.c: In function ‘PhaseRecurse’:
UnWrap.c:330:3: warning: incompatible implicit declaration of built-in function ‘abort’ [enabled by default]
UnWrap.c:346:8: warning: extra tokens at end of #endif directive [enabled by default]
UnWrap.c: At top level:
UnWrap.c:454:8: warning: extra tokens at end of #endif directive [enabled by default]
UnWrap.c:488:8: warning: extra tokens at end of #endif directive [enabled by default]
In file included from UnWrap2d.c:14:0:
diffract.h:41:57: warning: conflicting types for built-in function ‘csqrt’ [enabled by default]
diffract.h:42:43: warning: conflicting types for built-in function ‘cexp’ [enabled by default]
UnWrap2d.c: In function ‘UnWrap2d’:
UnWrap2d.c:48:8: warning: extra tokens at end of #endif directive [enabled by default]
In file included from cfft.c:14:0:
diffract.h:41:57: warning: conflicting types for built-in function ‘csqrt’ [enabled by default]
diffract.h:42:43: warning: conflicting types for built-in function ‘cexp’ [enabled by default]
In file included from cfft2d.c:14:0:
diffract.h:41:57: warning: conflicting types for built-in function ‘csqrt’ [enabled by default]
diffract.h:42:43: warning: conflicting types for built-in function ‘cexp’ [enabled by default]
In file included from chamming.c:14:0:
diffract.h:41:57: warning: conflicting types for built-in function ‘csqrt’ [enabled by default]
diffract.h:42:43: warning: conflicting types for built-in function ‘cexp’ [enabled by default]
In file included from cmodulate.c:14:0:
diffract.h:41:57: warning: conflicting types for built-in function ‘csqrt’ [enabled by default]
diffract.h:42:43: warning: conflicting types for built-in function ‘cexp’ [enabled by default]
In file included from comm.c:14:0:
diffract.h:41:57: warning: conflicting types for built-in function ‘csqrt’ [enabled by default]
diffract.h:42:43: warning: conflicting types for built-in function ‘cexp’ [enabled by default]
comm.c: In function ‘comm’:
comm.c:28:2: warning: incompatible implicit declaration of built-in function ‘exit’ [enabled by default]
In file included from complex.c:15:0:
diffract.h:41:57: warning: conflicting types for built-in function ‘csqrt’ [enabled by default]
diffract.h:42:43: warning: conflicting types for built-in function ‘cexp’ [enabled by default]
In file included from ctranspose.c:14:0:
diffract.h:41:57: warning: conflicting types for built-in function ‘csqrt’ [enabled by default]
diffract.h:42:43: warning: conflicting types for built-in function ‘cexp’ [enabled by default]
In file included from ellipse.c:14:0:
diffract.h:41:57: warning: conflicting types for built-in function ‘csqrt’ [enabled by default]
diffract.h:42:43: warning: conflicting types for built-in function ‘cexp’ [enabled by default]
ellipse.c: In function ‘readellipses’:
ellipse.c:33:3: warning: incompatible implicit declaration of built-in function ‘exit’ [enabled by default]
ellipse.c:38:3: warning: incompatible implicit declaration of built-in function ‘exit’ [enabled by default]
fft.c: In function ‘fft’:
fft.c:39:15: warning: conflicting types for built-in function ‘sin’ [enabled by default]
fft.c:39:22: warning: conflicting types for built-in function ‘cos’ [enabled by default]
In file included from findpoint.c:14:0:
diffract.h:41:57: warning: conflicting types for built-in function ‘csqrt’ [enabled by default]
diffract.h:42:43: warning: conflicting types for built-in function ‘cexp’ [enabled by default]
In file included from findray.c:14:0:
diffract.h:41:57: warning: conflicting types for built-in function ‘csqrt’ [enabled by default]
diffract.h:42:43: warning: conflicting types for built-in function ‘cexp’ [enabled by default]
findray.c: In function ‘findray’:
findray.c:147:4: warning: incompatible implicit declaration of built-in function ‘exit’ [enabled by default]
In file included from findscat.c:16:0:
diffract.h:41:57: warning: conflicting types for built-in function ‘csqrt’ [enabled by default]
diffract.h:42:43: warning: conflicting types for built-in function ‘cexp’ [enabled by default]
findscat.c: In function ‘findscat’:
findscat.c:187:3: warning: incompatible implicit declaration of built-in function ‘abort’ [enabled by default]
findscat.c:187:3: error: too many arguments to function ‘abort’
findscat.c:197:3: warning: incompatible implicit declaration of built-in function ‘abort’ [enabled by default]
findscat.c:197:3: error: too many arguments to function ‘abort’
findscat.c:207:4: warning: incompatible implicit declaration of built-in function ‘abort’ [enabled by default]
findscat.c:207:4: error: too many arguments to function ‘abort’
findscat.c: At top level:
findscat.c:303:7: warning: extra tokens at end of #else directive [enabled by default]
findscat.c:314:8: warning: extra tokens at end of #endif directive [enabled by default]
In file included from hamming.c:14:0:
diffract.h:41:57: warning: conflicting types for built-in function ‘csqrt’ [enabled by default]
diffract.h:42:43: warning: conflicting types for built-in function ‘cexp’ [enabled by default]
In file included from mode.c:14:0:
diffract.h:41:57: warning: conflicting types for built-in function ‘csqrt’ [enabled by default]
diffract.h:42:43: warning: conflicting types for built-in function ‘cexp’ [enabled by default]
numout.c:31:8: warning: extra tokens at end of #endif directive [enabled by default]
picout.c: In function ‘picout’:
picout.c:29:4: warning: passing argument 2 of ‘fwrite’ makes integer from pointer without a cast [enabled by default]
In file included from picout.c:17:0:
/usr/include/stdio.h:715:15: note: expected ‘size_t’ but argument is of type ‘char *’
picout.c:29:4: error: too few arguments to function ‘fwrite’
picout.c:30:4: warning: incompatible implicit declaration of built-in function ‘exit’ [enabled by default]
syntax.c: In function ‘syntax’:
syntax.c:15:2: warning: incompatible implicit declaration of built-in function ‘exit’ [enabled by default]
In file included from Green.c:5:0:
diffract.h:41:57: warning: conflicting types for built-in function ‘csqrt’ [enabled by default]
diffract.h:42:43: warning: conflicting types for built-in function ‘cexp’ [enabled by default]
Green.c: In function ‘Green’:
Green.c:37:27: warning: incompatible implicit declaration of built-in function ‘malloc’ [enabled by default]
Green.c:58:8: warning: extra tokens at end of #endif directive [enabled by default]
Green.c:59:27: warning: incompatible implicit declaration of built-in function ‘malloc’ [enabled by default]
Green.c:63:5: warning: incompatible implicit declaration of built-in function ‘exit’ [enabled by default]
Green.c:89:3: warning: incompatible implicit declaration of built-in function ‘exit’ [enabled by default]
make: *** [libuis] Error 1

I assume I have to compile libuis on my machine for this to work? Cheers, Paul

Paul
  • 85
  • 5
  • And the diffract.h in /Src is empty.. –  Oct 25 '13 at 07:56
  • 1
    `ncc` is what it's trying to compile with- find the line that contains `ncc` in Makefile and change it to something like `gcc` which you will probably have installed. – Leigh Oct 25 '13 at 07:57
  • The Lib folder has `libuis` which is the compiled output of the Lib source code. Copy that file into the Src folder as `libuis.a` ( so `cp ../Lib/libuis ./libuis.a`) Then run make again. With your mod to the `Makefile` to use gcc you now get a whole bunch of c error messages. Which is at least progress of a sort. – GregHNZ Oct 25 '13 at 08:02
  • 2
    Don't replace ncc with gcc! You're looking for http://www.tinyos.net/tinyos-1.x/doc/nesc/ncc.html – alexandernst Oct 25 '13 at 08:11
  • Or you might be looking for the Norcroft C Compiler from about that era. Might be hard to get though. http://www.codemist.co.uk/ncc/index.html – GregHNZ Oct 25 '13 at 08:23
  • I really like the file `scat.c`. – Daniel Kamil Kozar Oct 25 '13 at 08:35
  • @GregHNZ Thanks! I will write them. Maybe they can help. – Paul Oct 25 '13 at 08:49
  • I have a feeling that several of the errors you're now getting, are because those types, variables and constants are defined in `diffract.h`, but that's an empty file!. You'd better check that it's really empty, or that something went wrong when obtaining `diffract.h`. –  Oct 25 '13 at 08:51
  • Addition to my previous comment: copy or symlink `Lib/diffract.h` to `Src/diffract.h` and your compilation may get a lot further. That, or update the Makefile to set your include path to `Lib`. –  Oct 25 '13 at 08:53
  • @GregHNZ The very kind people from Codemist Ltd ruled out the Norcroft compiler: There is an `#ifdef BSD` statement and the Norcroft compiler was not used on BSD systems. – Paul Oct 25 '13 at 09:47

1 Answers1

3

To get rid of most of the "conflicting types for built-in function" warnings add

#include <stdlib.h>`

to diffract.h and add -std=c89 to CFLAGS in the Makefile. To get the stuff in Src to use the diffract.h in Lib you can use a symlink; another option is adding also -I../Lib to CFLAGS:

CFLAGS=-g -std=c89 -I../Lib

This will make it much easier to find the actual errors.

Some errors you'll have to fix by hand. For example picout.c tries to use fwrite as if it was fprintf, which makes me wonder if this code was ever working:

/* was: fwrite(stderr,"Error in writing picture.\n"); */
fprintf(stderr,"Error in writing picture.\n");

The UnWrap.c file uses a symbolic constant called HUGE which is not defined anywhere. In files under the RCS directory you can find this declaration, which you can add to diffract.h:

#define HUGE    1.701411733192644270e38

Also in a few places there are calls to abort(1), which is an error because the abort function takes no parameters. In those cases just remove the 1. Other than that the code seems to compile on GCC.

Joni
  • 108,737
  • 14
  • 143
  • 193