我正在尝试在 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
, -msse
然后添加错误目录部分的路径。
cc -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
您可以通过此链接访问源代码; Source Code
我的电脑信息:
操作系统:Ubuntu 18.04.2 LTS
内核版本:4.15.0-50-generic
GCC 版本:7.4.0
最佳答案
gets
在 C11 中被删除。使用gcc -o mol_volume -Wall -std=c99 -mtune=native -O3 mol_volume.c -lm
进行编译。
它会起作用,但您应该修复代码以删除所有警告。
关于c - 我应该如何用 cc 编译这个旧代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56199176/