将Fortran转换为C时使用f2c进行链接时出错 [英] Error in linking when converting Fortran to C (using f2c)
问题描述
我正在尝试构建一个大多数为C但具有一些Fortran子例程的项目。代码是旧的,我试图使它在现代机器上工作。我的主要函数调用一个外部函数
extern void __stdcall mainlhs(void);
该函数是一个用Fortan编写的子程序
子程序mainlhs
我想将Fortran代码其中包含这个和其他子程序)使用f2c并将结果放到我的项目中。
错误35错误LNK2019:无法解析的外部符号_e_wsle在函数_mainlhs_中引用C:\Users\giazlas\Documents\Socrates Support\projects\lhsforc\lhsforc\UNCER.obj
错误36错误LNK2019:无法解析的外部符号_s_wsle在函数_mainlhs_中引用C:\ Users \giazlas\Documents\Socrates Support\projects\lhsforc\lhsforc\UNCER.obj
错误37错误LNK2019:无法解析的外部符号_f_clos在函数_mainlhs_中引用C:\ Users \ giazlas \Documents\Socrates Support\projects\lhsforc\lhsforc\UNCER.obj
错误38错误LNK2019:无法解析的外部符号_e_rsle在函数_mainlhs_中引用C:\ Users \ giazlas \Documents\\ \\Socrates支持\projects\lhsforc\lhsforc\UNCER.obj
错误39错误LNK2019:无法解析的外部符号_do_lio在函数_mainlhs_中引用C:\Users\giazlas\Documents\Socrates Support\projects\lhsforc\lhsforc\UNCER.obj
错误40错误LNK2019:无法解析的外部符号_s_rsle在函数_mainlhs_中引用C:\Users\giazlas\Documents\Socrates Support\projects\lhsforc\lhsforc\UNCER.obj
错误41错误LNK2019:无法解析的外部符号_f_open在函数_mainlhs_中引用C:\ Users \giazlas\Documents\Socrates Support\projects\lhsforc\lhsforc\UNCER.obj
错误42错误LNK2019:无法解析的外部符号_s_stop在函数_chlsky_中引用C:\ Users \giazlas\Documents\Socrates Support\projects\lhsforc\lhsforc\UNCER.obj
错误43错误LNK2019:无法解析的外部符号_e_wsfe在函数_gaminv_中引用C:\ Users \ giazlas \Documents\Socr ates Support\projects\lhsforc\lhsforc\UNCER.obj
错误44错误LNK2019:无法解析的外部符号_do_fio在函数_gaminv_中引用C:\ Users \ giazlas \Documents \Socrates Support \ projects \ lhsforc\lhsforc\UNCER.obj
错误45错误LNK2019:无法解析的外部符号_s_wsfe在函数_gaminv_中引用C:\Users\giazlas\Documents\Socrates Support\projects\lhsforc \lhsforc\UNCER.obj
错误46错误LNK2019:无法解析的外部符号_pow_dd在函数_gamcdf_中引用C:\ Users \\ \\ giazlas \Documents \Socrates Support \projects\lhsforc\lhsforc\\ \\ UNCER.obj
错误47错误LNK2019:无法解析的外部符号_pow_ri在函数_moment_中引用C:\Users\giazlas\Documents\Socrates Support\projects\lhsforc\lhsforc\UNCER.obj
错误48错误LNK2019:无法解析的外部错误符号_s_paus在函数_betpdf_中引用C:\ Users \giazlas\Documents\Socrates Support\projects\lhsforc\lhsforc\UNCER.obj
这些函数不会出现在原始Fortran代码或其他任何地方。我只在netlib的f2c源代码中找到它们的引用。
感谢您的帮助解决方案 div>我认为你还需要链接libf2c中的函数,这个函数可以从Netlib中获得,如 http://www.netlib.org/f2c/README 。
I'm trying to build a project that is mostly C but has some Fortran subroutines. The code is old and I'm trying to make it work on modern machines. My main function calls an external function
extern void __stdcall mainlhs(void);
The function is a subroutine written in Fortan
subroutine mainlhs
I want to convert the Fortran code (which contains this and other subroutines) using f2c and put the result in my project.
f2c does convert the code and the resulting C code does compile. When I try to build the project there are several linking errors.
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
these functions don't appear on the original Fortran code nor anywhere else. I only found references of them on netlib's source of f2c
Thanks for your help
I think you also need to link the functions in libf2c, which is avaiable from Netlib, as described at http://www.netlib.org/f2c/README .
这篇关于将Fortran转换为C时使用f2c进行链接时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!