admin管理员组文章数量:1122832
I am trying to link an application compiled with gcc 8.5.0 to c and Fortran libraries compiled with gcc 8.5.0 and gfortran (version unknown) on Oracle Linux (a RedHat derivative). Linking to the gcc compiled library works just fine, so I will omit details. Linking the C application to the Fortran library gives me undefined references, however. The issue seems to be with a trailing/appended underscore in the exported symbols of the Fortran library. I have no control over the Fortran library.
My C code calls the Fortran symbols as so: foo_c_app.exe:
foo_fortran_routine(x, y, z);
If I change the calls to:
foo_fortran_routine_(x, y, z);
Linking works without error. All of the code is considered legacy and worked in the past with simple compiler options. I would like to not change the code to get it to compile and link without error, as was done before, is it possible, if so how?
Also, when I execute nm
on the Fortran library, I get:
T foo_fortran_routine_
Thus far, I have tried using gcc and gfortran for linking with various options, but nothing has worked. The only thing that works is adding the trailing underscore to the function calls in the C code, which is not ideal in my opinion.
本文标签: linking gcc compiled c application to c and gfortran librariesStack Overflow
版权声明:本文标题:linking gcc compiled c application to c and gfortran libraries - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736300490a1930834.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论