使用 VS2015 在 Windows 10 上构建 Fortran .lib x64 位并将其链接到 C++

build Fortran .lib x64 bit on windows 10 using VS2015 and link it to C++

本文关键字:链接 C++ x64 lib Windows VS2015 Fortran 构建 使用      更新时间:2023-10-16

我正在使用VS2015构建一个c ++和Fortran混合程序,这在Windows 7上非常好。首先构建了Fortran XXX.lib,然后链接到C++ XXX_main(构建依赖项->项目依赖项(。现在我正在尝试使用目标计算机x10将其迁移到Windows 64,但仍使用VS2015,并且存在编译错误,经过数周搜索后我找不到解决方案。

以下是编译信息:

------ Neues Erstellen gestartet: Projekt: XXX, Konfiguration: Debug x64 ------
1>Deleting intermediate files and output files for project 'XXX', configuration 'Debug|x64'.
1>Compiling with Intel(R) Visual Fortran Compiler 19.0.5.281 [Intel(R) 64]...
1>scout2d.f
1>E:testsrcscout2d.f(74): error #8110: The module file for compiler-generated interface was generated for a different platform or by an incompatible compiler or compiler release. It cannot be read. Use -gen-interfaces option.   [XGET__GENMOD]
1>fortcom: Fatal: There has been an internal compiler error (C0000005).
1>compilation aborted for E:testsrcscout2d.f (code 1)
...........
1>scp_lib - 82 error(s), 18 warning(s)
1>XXX - 82 error(s), 18 warning(s)
2>------ Neues Erstellen gestartet: Projekt: XXX_main, Konfiguration: Debug x64 ------
...........
2>  XXX_main.vcxproj -> E:testx64DebugXXX_main.exe
2>  XXX_main.vcxproj -> E:testx64Debug/XXX_main.pdb (Full PDB)
========== Alles neu erstellen: 1 erfolgreich, 1 fehlerhaft, 0 übersprungen ==========

源文件当然与Windows 7相同。以下是我使用 VS10 在 Windows 2015 上对 x64 系统所做的更改。欢迎任何建议。谢谢!

  1. XXX_main项目属性 -> 链接器 ->输入 -> 其他依赖项和库:与以前相同
  2. XXX_main项目属性 -> C++ -> 包含文件夹:与以前相同
  3. XXX_main项目属性 ->链接器 ->高级 -> 目标计算机:将计算机 X84 更改为计算机 X64
  4. 配置管理器 -> 平台:x64
  5. 选项 ->
  6. 英特尔编译器和工具 -> C++ -> 编译器:将 win32 更改为 x64
  7. 选项 ->
  8. 英特尔编译器和工具 ->Visual Fortran -> 编译器 -> 包含:添加 $(IFORT_COMPILER15(\编译器\包含 -> 库:添加 $(IFORT_COMPILER15(\编译器\lib\intel64
  9. 卸载并重新安装Fortran编译器,当前版本为: 英特尔(R( Visual Fortran 英特尔(R( 64 编译器,适用于在英特尔(R( 64 版本 19.0.5 上运行的应用程序
  10. 卸载和重新安装 Visual Studio 2015,当前版本为 14.0.25431.01
    Update 3
  11. Fortran XXX 项目属性 -> 库 -> 输出:x64\调试\XXX.lib

我已经找到了解决方案。这是我所做的:

  1. 卸载英特尔 Fortran 编译器(重新启动 PC(并重新安装(重新启动 PC(
  2. 右键单击 Fortran 项目 XXX -> 属性 -> Fortran -> 外部过程 -> 调用约定:将其更改为CVF(/iface:cvf(。
  3. 右键单击C++项目XXX_main ->属性 -> VC++ 文件夹 -> 库文件夹:添加 Fortran 编译器路径 $(IFORT_COMPILER19(\编译器\lib\intel64

无论如何,感谢您的帮助。 此致敬意