问题
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