无法在代码块13.12中编译.f(fortran文件) [英] Unable to compile .f (fortran file) in codeblocks 13.12

查看:62
本文介绍了无法在代码块13.12中编译.f(fortran文件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Windows 8上的Code :: Blocks中执行Give fortran代码

I am trying to execute give fortran code in Code::Blocks on Windows 8

   program main
   write (*,*) "hi"
   stop
   end

我得到的错误是

G:\Study\Programs\bairstow.o:bairstow.f undefined reference to `_gfortran_st_write'
G:\Study\Programs\bairstow.o:bairstow.f undefined reference to `_gfortran_transfer_character_write'
G:\Study\Programs\bairstow.o:bairstow.f undefined reference to `_gfortran_st_write_done'
G:\Study\Programs\bairstow.o:bairstow.f undefined reference to `_gfortran_stop_string'
G:\Study\Programs\bairstow.o:bairstow.f undefined reference to `_gfortran_set_args'
G:\Study\Programs\bairstow.o:bairstow.f undefined reference to `_gfortran_set_options'
=== Build failed: 6 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===

我将.f文件复制粘贴到编译器本身的文件夹中,并执行命令

I copy pasted the .f file in the folder of the compiler itself and executed the command

gfortran.exe hello.f

.exe输出文件已成功生成并执行.我不确定是否在C :: B中正确设置了编译器.我可能会缺少什么?

The output .exe file is successfully generated and executed. I am not sure if I have setup the compiler properly in C::B. What I might be missing?

更新:正如janneb建议的那样,我添加了链接程序库路径,以便使用libgfortran-3.dll.使用以下构建日志成功编译了文件:

UPDATE : As suggested by janneb, I added the linker library path so as to use libgfortran-3.dll. The file gets compiled successfully with the following build log :

mingw32-g++.exe   -c G:\Study\Programs\bairstow.f -o G:\Study\Programs\bairstow.o
mingw32-g++.exe  -o G:\Study\Programs\bairstow.exe G:\Study\Programs\bairstow.o   "C:\Program Files (x86)\CodeBlocks\MinGW\bin\libgfortran-3.dll"
Process terminated with status 0 (0 minute(s), 1 second(s))
0 error(s), 0 warning(s) (0 minute(s), 1 second(s))

执行文件时,等待约2分钟后,出现以下错误:在链接库文件时是否犯了任何错误?

When I execute the file, after waiting for about 2 minutes, I get the following error: Have I made any mistake in linking the library file?

提示:它也弄乱了我的GNU C编译器.现在,即使取消链接libgfortran-3.dll,我也无法执行简单的helloWorld.c程序.

Hint : It has messed up with my GNU C Compiler also. Now even after unlinking the libgfortran-3.dll, I can't execute a simple helloWorld.c program.

推荐答案

基于错误消息,当您通过C :: B进行编译时,您没有链接GFortran运行时库(libgfortran).gfortran.exe驱动程序会自动处理此问题,因此很可能您正在使用gcc.exe进行编译,该gcc.exe基于文件扩展名可以调用Fortran编译器(f951),但不执行gfortran.exe所做的链接工作

Based on the error message you're not linking the GFortran runtime library (libgfortran) when compiling via C::B. The gfortran.exe driver program automatically handles this, so most likely you're compiling with gcc.exe, which based on the file extension can invoke the Fortran compiler (f951), but doesn't do the linking stuff that gfortran.exe does.

无论如何,我从未在Windows上使用过C :: B或gfortran,但希望上面的解释为您提供了从哪里开始寻找的提示.

Anyway, I have never used C::B nor gfortran on Windows, but hopefully the above explanation gives you a hint where to start looking.

这篇关于无法在代码块13.12中编译.f(fortran文件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆