简体   繁体   English

将MinGW64 .o链接到MSVC 2010

[英]Link MinGW64 .o to MSVC 2010

How can I link object files produced with MinGW64 fortran (gfortran) compiler (.o) to MSVC 2010? 如何将用MinGW64 fortran(gfortran)编译器(.o)生成的目标文件链接到MSVC 2010?

I just want to use 64 bit arpack library with 64 bit MSVC solution, but all other ways to do it were unsuccessful. 我只想将64位arpack库与64位MSVC解决方案一起使用,但其他所有方法均无法成功。 MSVC finds arpack functions with 32 bit solution's configuration but starts application with a runtime error and can't find arpack function with 64 bit solution's configuration at all. MSVC可以找到具有32位解决方案配置的arpack函数,但会在运行时错误时启动应用程序,而根本找不到具有64位解决方案配置的arpack函数。

Short answer: you can't. 简短的答案:您不能。 Those compilers use different ABI's meaning their object file format is different and incompatible. 这些编译器使用不同的ABI表示它们的目标文件格式不同且不兼容。

What might be possible is to let create MinGW a DLL out of the Fortran code. 可能的是让Fortran代码中的DLL创建MinGW。 Import that into your C++ Program, but beware of name mangling: The Symbols exported by the DLL must not be mangled (I am not sure if there is name mangling in Fortran at all). 将其导入到您的C ++程序中,但要注意名称修饰:DLL所导出的符号不能被修饰(我不确定Fortran中是否存在名称修饰)。 In your C++ code the functions imported from the DLL have to be declared "extern C" to prevent name mangling on the C++ side. 在您的C ++代码中,必须将从DLL导入的函数声明为“ extern C”,以防止在C ++方面进行名称修饰。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM