古い FORTRAN 77 プログラムを使用していますが、通常どおりにコンパイル/ビルドするのに問題があります。
gfortran -Wall -o "filename" filename.f
リンカーエラーが発生し続けます:
$ gfortran -Wall ljewald.f
/usr/lib/gcc/i686-linux-gnu/4.7/../../../i386-linux-gnu/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: error: ld returned 1 exit status
最終的に、私は試しました:gfortran -Wall -c -o "filename" filename.f
コンパイルされたバイナリファイルが得られます。わかりましたが、gfortran のマニュアル ページは私をスケッチしています。これがすべて機能しているように見える -c オプションの資料は次のとおりです。
-C Do not discard comments. All comments are passed through to the output file, except for comments in processed directives, which are deleted
along with the directive.
You should be prepared for side effects when using -C; it causes the preprocessor to treat comments as tokens in their own right. For example,
comments appearing at the start of what would be a directive line have the effect of turning that line into an ordinary source line, since the
first token on the line is no longer a '#'.
Warning: this currently handles C-Style comments only. The preprocessor does not yet recognize Fortran-style comments.
したがって、これをビルドした後、次を使用します。
gfortran -Wall -c -o "ljewald" ljewald.f
出力ファイルを取得しましたが、実行可能ファイルではありません...?
$ls -l
...
-rw-rw-r-- 1 j0h j0h 647 Aug 9 16:36 ljewald
...
chmod +x ljewald でモードを変更しても、このファイルを実行できません
-c オプションの使用にはクセがあるため、これを回避するにはどうすればよいですか? また、このプログラムの実行可能ファイルを作成するにはどうすればよいですか? 誰かが説明して、これを修正する方法を教えてもらえますか:?
/usr/lib/gcc/i686-linux-gnu/4.7/../../../i386-linux-gnu/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: error: ld returned 1 exit status