I'm trying to compile source code, that from 2001, in Ubuntu 18.04.2 LTS. But, I got the errors below and actually don't know how I have to change the compiling code. Can you help me for compiling this code?

Suggested compilation part from the program

  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

When I tried this code, errors;

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’?

Then, I changed -fast, -tune, -arch, -assume flags with -Ofast, -mtune=native, -march=native, -msse then add the path the for the directory part of the errors.

cc -lm -Ofast -mtune=native -march=native -msse /mypath/ -o mol_volume mol_volume.c

Then, I got that error;

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

You can access the source code via this link; Source Code

My PC info:

Operation System: Ubuntu 18.04.2 LTS

Kernel ver.: 4.15.0-50-generic

GCC ver.: 7.4.0

1 Answers

1
Antoine Mathys On

gets was removed in C11. Compile with gcc -o mol_volume -Wall -std=c99 -mtune=native -O3 mol_volume.c -lm.

It will work but you should fix the code to remove all the warnings.