我从Don Knuth下载了CWEB程序-特别是
http://www-cs-faculty.stanford.edu/~knuth/programs/sliding.w
我将sliding.w转换为sliding.c
现在,我尝试使用以下命令对其进行编译:


  gcc slide.c -o滑动


但是然后我得到:

./sliding.w:116:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
 main(int argc, char *argv[])
 ^
/tmp/cc9NVnXq.o: In function `main':
sliding.c:(.text+0x2006): undefined reference to `gb_init_rand'
sliding.c:(.text+0x201c): undefined reference to `gb_fptr'
sliding.c:(.text+0x202b): undefined reference to `gb_fptr'
sliding.c:(.text+0x2036): undefined reference to `gb_fptr'
sliding.c:(.text+0x2047): undefined reference to `gb_flip_cycle'
collect2: error: ld returned 1 exit status


谁能帮我?

最佳答案

第一个问题只是警告。致命的错误是您缺少在此处定义的gb_符号:

http://ftp.cs.stanford.edu/pub/sgb/gb_flip.w

因此,首先需要将gb_flip.w编译为.c文件,然后将两个.c文件一起编译,如下所示:

gcc sliding.c gb_flip.c -o sliding

08-27 22:00