Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top