将Fortran转换为C时链接出错(使用f2c)

时间:2014-05-13 20:08:17

标签: visual-studio-2010 visual-c++ linker fortran f2c

我正在尝试构建一个主要是C但有一些Fortran子程序的项目。代码很旧,我试图让它在现代机器上运行。我的主函数调用外部函数

extern void __stdcall mainlhs(void);

该函数是用Fortan编写的子程序

subroutine mainlhs

我想使用f2c转换Fortran代码(包含此子程序和其他子程序)并将结果放入我的项目中。

f2c会转换代码,生成的C代码会编译。当我尝试构建项目时,会出现几个链接错误。

Error   35  error LNK2019: unresolved external symbol _e_wsle referenced in function _mainlhs_  C:\Users\giazlas\Documents\Socrates Support\projects\lhsforc\lhsforc\UNCER.obj
Error   36  error LNK2019: unresolved external symbol _s_wsle referenced in function _mainlhs_  C:\Users\giazlas\Documents\Socrates Support\projects\lhsforc\lhsforc\UNCER.obj
Error   37  error LNK2019: unresolved external symbol _f_clos referenced in function _mainlhs_  C:\Users\giazlas\Documents\Socrates Support\projects\lhsforc\lhsforc\UNCER.obj
Error   38  error LNK2019: unresolved external symbol _e_rsle referenced in function _mainlhs_  C:\Users\giazlas\Documents\Socrates Support\projects\lhsforc\lhsforc\UNCER.obj
Error   39  error LNK2019: unresolved external symbol _do_lio referenced in function _mainlhs_  C:\Users\giazlas\Documents\Socrates Support\projects\lhsforc\lhsforc\UNCER.obj
Error   40  error LNK2019: unresolved external symbol _s_rsle referenced in function _mainlhs_  C:\Users\giazlas\Documents\Socrates Support\projects\lhsforc\lhsforc\UNCER.obj
Error   41  error LNK2019: unresolved external symbol _f_open referenced in function _mainlhs_  C:\Users\giazlas\Documents\Socrates Support\projects\lhsforc\lhsforc\UNCER.obj
Error   42  error LNK2019: unresolved external symbol _s_stop referenced in function _chlsky_   C:\Users\giazlas\Documents\Socrates Support\projects\lhsforc\lhsforc\UNCER.obj
Error   43  error LNK2019: unresolved external symbol _e_wsfe referenced in function _gaminv_   C:\Users\giazlas\Documents\Socrates Support\projects\lhsforc\lhsforc\UNCER.obj
Error   44  error LNK2019: unresolved external symbol _do_fio referenced in function _gaminv_   C:\Users\giazlas\Documents\Socrates Support\projects\lhsforc\lhsforc\UNCER.obj
Error   45  error LNK2019: unresolved external symbol _s_wsfe referenced in function _gaminv_   C:\Users\giazlas\Documents\Socrates Support\projects\lhsforc\lhsforc\UNCER.obj
Error   46  error LNK2019: unresolved external symbol _pow_dd referenced in function _gamcdf_   C:\Users\giazlas\Documents\Socrates Support\projects\lhsforc\lhsforc\UNCER.obj
Error   47  error LNK2019: unresolved external symbol _pow_ri referenced in function _moment_   C:\Users\giazlas\Documents\Socrates Support\projects\lhsforc\lhsforc\UNCER.obj
Error   48  error LNK2019: unresolved external symbol _s_paus referenced in function _betpdf_   C:\Users\giazlas\Documents\Socrates Support\projects\lhsforc\lhsforc\UNCER.obj

这些功能不会出现在原始的Fortran代码上,也不会出现在其他任何地方。我只在netlib的f2c

源上找到了它们的引用

感谢您的帮助

1 个答案:

答案 0 :(得分:2)

我认为您还需要链接libf2c中的函数,这些函数可以从Netlib获得,如http://www.netlib.org/f2c/README所述。