2

我正在尝试从 1988 年开始编译一个程序。该程序从计算机断层扫描类型的实验中计算二维重建 - 只有它考虑了光的一阶衍射。我在那里上传了档案:

http://ubuntuone.com/1LXF5SBtUToJZ2lSgGJS47

它包含三个文件夹:

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

Srcand都Lib包含一个. Makefile当我尝试编译时,我得到:

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

[编辑] 正如 alexandernst 所建议的,我在 Makefile 中安装了nescc并用 nescc 替换了 ncc。

该文件libuis位于Lib. 当我尝试编译时:

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

[编辑] 根据 greghnz 的建议,我复制Lib/libuisSrc/libuis.a.

[编辑] 正如 Evert 所建议的,我符号链接Lib/diffract.hSrc/diffract.h并且编译更进一步。

当我现在尝试编译时,我得到:

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

我跑了(我不知道那是做什么的)

ranlib libuis.a

并没有返回任何东西。当我重命名Lib/libuis并尝试编译它时,我得到了这个:

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

我假设我必须在我的机器上编译libuis才能工作?干杯,保罗

4

1 回答 1

3

要摆脱大多数“内置函数的冲突类型”警告,请添加

#include <stdlib.h>`

diffract.h 并添加-std=c89到 Makefile 中的 CFLAGS。要让 Src 中的内容使用 Lib 中的 diffract.h,您可以使用符号链接;另一种选择是也添加-I../Lib到 CFLAGS:

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

这将使查找实际错误变得更加容易。

您必须手动修复一些错误。例如picout.c尝试使用fwriteas if it is fprintf,这让我想知道这段代码是否曾经工作过:

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

UnWrap.c文件使用一个HUGE未在任何地方定义的符号常量。在 RCS 目录下的文件中,您可以找到此声明,您可以将其添加到 diffract.h:

#define HUGE    1.701411733192644270e38

也有一些地方调用了abort(1),这是一个错误,因为 abort 函数没有参数。在这些情况下,只需删除1. 除此之外,代码似乎可以在 GCC 上编译。

于 2013-10-25T11:01:12.267 回答