Error in linking when converting Fortran to C (using f2c)

别说谁变了你拦得住时间么 提交于 2019-12-25 12:52:12

问题


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


回答1:


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 .



来源:https://stackoverflow.com/questions/23640655/error-in-linking-when-converting-fortran-to-c-using-f2c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!