BrianGladman / mpir

Multiple Precision Integers and Rationals
GNU General Public License v3.0
75 stars 36 forks source link

How to build DLL GMPXX? #14

Closed ghost closed 4 years ago

ghost commented 4 years ago

The lib_mpir_cxx project can generate only static library of GMPXX. How to generate DLL of GMPXX?

SanderBouwhuis commented 4 years ago

You can use any of the dllmpir* projects. I would recommend using the dll_mpir_pentium4_sse2 project if you want maximum compatibility. But, you can use more modern cpu generations as well.

You can use the "msvc\mpir_config.py" Python script to generate any type of project you want if you don't like the pre-generated ones. (see page 12 of the MPIR 3.0.0 pdf documentation)

BrianGladman commented 4 years ago

There are static libraries for the MPIR C and C++ interface but the MPIR DLL includes both so a separate C++ DLL is not needed.

ghost commented 4 years ago

I got it. CGAL needs to link to the DLL version of GMPXX, but I used lib rather than dll as the lib path. Now I changed both GMPXX_INCLUDE_DIR and GMPXX_LIBRARIES in cmake-gui to the dll path, and everything is all right. Thank you very much, BrianGladman.

gvanem commented 4 years ago

I comment here since the dllexport/dllimport stuff in MPIR is confusing as hell. E.g. gmp.h has tests for MSC_BUILD_DLL and MSC_USE_DLL (btw. this ass-u-mes it's refereing to mpir.dll only?).

I see not a single hit for MSC_BUILD_DLL and/or MSC_USE_DLL under msvc. So how on earth is it possible to build a mpirxx.dll?

BTW, stuff like:

is backwards. MSVC wants:

for data to be properly DLL-exported.

BrianGladman commented 4 years ago

The defines for building (MSC_BUILD_DLL) or using (MSC_USE_DLL) are set in the appropriate Visual Studio project files, not within the MPIR source code. The mpir DLL contains both the C and C++ features of MPIR so there is no mpirxx.dll

gvanem commented 4 years ago

.. are set in the appropriate Visual Studio project files ..

I fail to see how. I see MSC_BUILD_DLL is in _msvc_project.py. But not MSC_USE_DLL.

Edit: In other words, I'd ass-u-me the dependency for e.g. t-ostream.exe would be:

  t-ostream.exe
   |__ mpirxx.dll
       |__ mpir.dll
       |__ MSVCP140.dll
        etc...

but it looks instead it's fatter than need to be and really is:

  t-ostream.exe
   |__ mpirxx.dll  - all MPIR .c-files are duplicated here!
      |__ MSVCP140.dll
       etc...
BrianGladman commented 4 years ago

Yes, the DLL contains C++ interface code which won't be used if only the C interface is needed. But this overhead is small.

BrianGladman commented 4 years ago

If you want to play about with the build process, you are on your own I'm afraid as I don't have time to explain its internal structure and operation. I'll try to help if you run into problems in using the build.

gvanem commented 4 years ago

It would help to see the AppVeyor log/output. So I forked your project and added a job here: https://ci.appveyor.com/project/gvanem/mpir

... it failed though.

BrianGladman commented 4 years ago

The script is a hang over from the days when we ran a single repository (I don't build with Appveyor). If there is any information on how it fails I might be able to identify the issue that causes it to fail.