lammps / lammps

Public development project of the LAMMPS MD software package
https://www.lammps.org
GNU General Public License v2.0
2.23k stars 1.71k forks source link

Add MSVC support and add __declspec to library interface #635

Closed andeplane closed 3 years ago

andeplane commented 7 years ago

Summary

To be able to use LAMMPS as a dll-library on windows, additional keywords like __declspec(export) and __declspec(import) to have these functions available. A few compilation issues with MSVC also need to be taken care of.

Type of Issue

Suggestion for an Enhancement

Detailed Description (Enhancement Suggestion)

I discussed this with @rbberger during the LAMMPS workshop. I want to create a Windows build of Atomify where LAMMPS is being used as a library. A typical way to create libraries on Windows is

#if COMPILING_DLL
    #define DLLEXPORT __declspec(dllexport)
#else
    #define DLLEXPORT __declspec(dllimport)
#endif

and use DLLEXPORT in front of the exported library functions. -DCOMPILING_DLL is used during compilation of the library. This part I could do myself, but there are other issues when compiling LAMMPS with MSVC compilers since

  1. MSVS does not support variable-length arrays, and
  2. there were some other compilation issues @rbberger mentioned that he needed to discuss with @sjplimp to pick a good way to solve them.

@rbberger can add more details on this.

rbberger commented 7 years ago

just for reference, I already have a branch (https://github.com/rbberger/lammps/commit/f6def26d16863ec004d0b27a79a6fc5c10660e84) with some quick hacks to make it "work". But I need to go over them and solve those issues properly / discuss with Steve or Axel.

akohlmey commented 3 years ago

@andeplane @rbberger been reviewing old issues today. Three comments:

Thus MSVC support is still not fully there. Due to lack of time and limited access to corresponding platforms, this will not be done quickly unless a dedicated developer can be found that will do the porting and support the port. I don't expect any updates to this outside of items that we have already planned anyway, so I am closing this now.