Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot build shared libraries using CMake with MSVC and Intel Fortran compiler #448

Open
Baljak opened this issue May 12, 2020 · 3 comments

Comments

@Baljak
Copy link

Baljak commented May 12, 2020

Bug description
When setting CMake flag BUILD_SHARED_LIBS to ON, OpenFAST can't be built with MSVC and Intel Fortran compiler. Tested with MSVC 2015 and 2019 and ifort 18.0 and 19.0. The reason comes from the fact that DLLEXPORT is not defined for functions which need to be exported, so ifort is unable to produce .lib import libraries.

To Reproduce
Steps to reproduce the behavior:

  1. Compile with MSVC and Intel Fortran compiler, no matter the version
  2. See the link error, for example nwtclibs.lib not found even if nwtclibs.dll was compiled correctly.

Expected behavior
It should be possible to compile all libraries as DLLs using MSVC and Intel Fortran.

OpenFAST Version
2.2.0

**************************************************************************************************
 OpenFAST

 Copyright (C)  National Renewable Energy Laboratory
 Copyright (C)  Envision Energy USA LTD

 This program is licensed under Apache License Version 2.0 and comes with ABSOLUTELY NO WARRANTY.
 See the "LICENSE" file distributed with this software for details.
 **************************************************************************************************

 OpenFAST-v2.0.0
 Compile Info:
  - Architecture: 64 bit
  - Precision: double
  - Date: Nov 27 2018
  - Time: 17:19:38
 Execution Info:
  - Date: 11/29/2018
  - Time: 10:52:28-0700

System Information (please complete the following information):

  • OS: Windows 10 64
  • Compiler: MSVC 2019 and Intel Fortran Compiler 19.0
  • Compiler settings: BUILD_SHARED_LIBS set to ON
@bjonkman
Copy link
Contributor

On Windows (regardless of compiler), you need to explicitly state which routines can be called from within a DLL. None of the modules except MAP++ have been set up that way, so either the BUILD_SHARED_LIBS option should be removed or all of the modules need to have their source code modified to work this way. Personally, I would just remove that as a build option on Windows.

@rafmudaf
Copy link
Collaborator

I agree, @bjonkman, I'll check for that in CMake.

@Baljak
Copy link
Author

Baljak commented May 16, 2020

On Windows (regardless of compiler), you need to explicitly state which routines can be called from within a DLL.

Not exactly, this is only required with MSVC (and ifort on Windows since it relies on MSVC linker) to generate import librairies. MinGW does not require export definitions and as such works perfectly fine with the BUILD_SHARED_LIBS option.

I agree though that adding DLLEXPORT definitions to all functions which need to be exported would be quite long so it may be better to disable the option for MSVC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants