我应如何使用cc编译此旧代码

时间:2019-05-18 13:00:11

标签: c compiler-errors compilation

我正在尝试在Ubuntu 18.04.2 LTS中编译源于2001年的源代码。但是,我遇到了下面的错误,实际上不知道该如何更改编译代码。您能帮我编译这段代码吗?

程序中建议的编译部分

  SUGGESTED COMPILATION COMMAND LINE (FOR A DEC-ALPHA CC-COMPILER):

  cc -lm -fast -tune host -arch host -assume whole_program \
     -o mol_volume mol_volume.c

当我尝试这段代码时,出现错误;

cc: error: host: No such file or directory
cc: error: host: No such file or directory
cc: error: whole_program: No such file or directory
cc: error: unrecognized command line option ‘-fast’; did you mean ‘-Ofast’?
cc: error: unrecognized command line option ‘-tune’; did you mean ‘-mtune=’?
cc: error: unrecognized command line option ‘-arch’; did you mean ‘-march=’?
cc: error: unrecognized command line option ‘-assume’; did you mean ‘-msse’?

然后,我将-fast-tune-arch-assume-Ofast-mtune=native-march=native-mssecc -lm -Ofast -mtune=native -march=native -msse /mypath/ -o mol_volume mol_volume.c ,然后为错误的目录部分添加路径。

mol_volume.c: In function ‘main’:
mol_volume.c:235:10: warning: implicit declaration of function ‘gets’; did you mean ‘fgets’? [-Wimplicit-function-declaration]
   while( gets(s) ) {
          ^~~~
          fgets
mol_volume.c:311:26: warning: format ‘%i’ expects argument of type ‘int’, but argument 2 has type ‘long int’ [-Wformat=]
    printf("WARNING: the %i-th atom of the pdb file %s has an unknown chemical type %s.\n",
                         ~^
                         %li
      i+1, pdb_name, atom_type);
      ~~~                  
/usr/bin/ld: cannot find .: File format not recognized
collect2: error: ld returned 1 exit status

然后,我得到了那个错误;

printf("%s/%s", av[1], av[2]);

您可以通过此链接访问源代码。 Source Code

我的电脑信息:

操作系统:Ubuntu 18.04.2 LTS

内核版本: 4.15.0-50(通用)

GCC版本: 7.4.0

1 个答案:

答案 0 :(得分:1)

gets已在C11中删除。用gcc -o mol_volume -Wall -std=c99 -mtune=native -O3 mol_volume.c -lm编译。

它可以工作,但是您应该修复代码以删除所有警告。

相关问题