OpenFAST / openfast

Main repository for the NREL-supported OpenFAST whole-turbine and FAST.Farm wind farm simulation codes.
http://openfast.readthedocs.io
Apache License 2.0
688 stars 458 forks source link

Compiling openfast with Visual Studio #1133

Open Edward-Ernest opened 2 years ago

Edward-Ernest commented 2 years ago

Bug description Hello, I am new to open-fast(v8). I have tried to compiler open-fast with Visual Studio 2022 by running the solution file Fast.sln, but it gives me a warning output. And the it seems that Fast, Fastlib and Fast_simulink can't be loaded.

To Reproduce

Steps to reproduce the behavior: 1. Install Visual studio 2022 2. Install Intel BaseKit_p_2022.2.0.252 3. Install Intel HPCKit_p_2022.2.0.173 4. Open /OpenFAST/vs-build/FAST/FAST.sln and build it. Fast, Fastlib and Fast_simulink can't be load and Visual Studio gave output information here: ①D:\Users\research\Openfast_research\OPENFAST\openfast-main\vs-build\FAST\FAST.vfproj : error : Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.VisualStudio.Shell.Interop.IVsUpdateSolutionEvents'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{A9F86308-5EA7-485D-BAB8-E8989C3CFBDC}' failed due to the following error: 不支持此接口 (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). ②D:\Users\research\Openfast_research\OPENFAST\openfast-main\vs-build\FASTlib\FASTlib.vfproj : error : Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.VisualStudio.Shell.Interop.IVsUpdateSolutionEvents'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{A9F86308-5EA7-485D-BAB8-E8989C3CFBDC}' failed due to the following error: 不支持此接口 (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). ③D:\Users\research\Openfast_research\OPENFAST\openfast-main\vs-build\OpenFAST-Simulink\OpenFAST-Simulink.vfproj : error : Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.VisualStudio.Shell.Interop.IVsUpdateSolutionEvents'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{A9F86308-5EA7-485D-BAB8-E8989C3CFBDC}' failed due to the following error: 不支持此接口 (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). Any advice to how to resolve it? Thanks! **Screenshots** ![fast_unload](https://user-images.githubusercontent.com/100555183/168991185-cac5df11-d044-4832-bae8-f280ec0c7db9.JPG) ![unsupported](https://user-images.githubusercontent.com/100555183/168991211-d0ae36be-5def-4254-b016-74a19bf1131d.JPG)
bjonkman commented 2 years ago

If you right-click on the each of the unloaded Fortran projects, does it give you the option to reload them? They will have to be loaded before you can build.

Edward-Ernest commented 2 years ago

When I try to reload them, Visual Studio gives a result 'load failed' just like the figure below. And in the output information window, the are the same warning information that I mentioned above. load_fail

bjonkman commented 2 years ago

What version of Visual Studio 2022 are you using? This article says VS 2022 version 17.2 breaks all of the Fortran integrations. If you have a version after VS2022 17.0.2, you won't be able to get the OpenFAST solution to build.

Here's a chart on version compatibility: https://www.intel.com/content/www/us/en/developer/articles/reference-implementation/intel-compilers-compatibility-with-microsoft-visual-studio-and-xcode.html

Edward-Ernest commented 2 years ago

Tank you very much for informing me the problem of software version. Now I have re-installed Visual Studio 2019 16.11.15, and they can be loaded now. But when I try to rebuild it with FAST.sln, it shows a error info and many waring info like this. build_error

bjonkman commented 2 years ago

Could you post the text from the Output window when you build? I'd like to see where in the build order the error shows up.

Edward-Ernest commented 2 years ago

Here is the Output information you need. Thank you very much for your help

error_output.txt

bjonkman commented 2 years ago

I'm not exactly sure why this is giving you a linking error. It seems like the Intel integrations either aren't properly setting the path to the MKL libraries or the MKL libraries didn't get installed with the oneAPI installers.

I am wondering if it is related to this issue. Could you try to build with an x64 configuration instead of Win32?

Edward-Ernest commented 2 years ago

Thank you very much for your suggestion. I can now complete the Compiling of Fast with an x64 configuration. And I try every module inside Fast.sln. Only the module of Fast should change the compiling configuration, the rest can be complied normally with Win32

bjonkman commented 2 years ago

It looks like if you want to build for 32-bit Windows, you will have to download and install a separate 32-bit oneAPI base toolkit (which includes the 32-bit MKL) after you install the "normal" oneAPI base toolkit: https://www.intel.com/content/www/us/en/developer/tools/oneapi/base-toolkit-download.html?operatingsystem=window&distributions=webdownload&options=online. Otherwise, you can just build for x64.