BrianGladman / mpir

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

How do I compile with VS? #17

Closed BBlayne closed 4 years ago

BBlayne commented 4 years ago

I have tried to open the sln files for vs17 and vs19 but I have several issues. Config.h and gmp-mparam.h cannot be found. I found a .bet file I think to genergate config.h but the config.h generated seems all wrong. I get errors such as:

unexpected in macro definition

'HAVENATIVE' macro redefinition Seems like all the macros are kinda sorta commented out?

define HAVENATIVE/* 1

#define HAVE_NATIVE_Copyright 1 

Like so.

When I try to use the Command Tools prompt, I get the following error: '\msbuild.exe' is not recognized as an internal or external command, operable program, or batch file. '-latest' is also not recognized.

BrianGladman commented 4 years ago

Can you tell me more about which version of MPIR you are trying to build. Are you building the generic C version, are you building a static library or a DLL. To check out what is wrong, it would be best to start with a clean copy of MPIR cloned from this repository and try to build the lib_mpir_gc version.

BBlayne commented 4 years ago

Hi, thanks for responding quickly!

I think I was trying to build lib_mpir_cxx. I opened mpir.sln in Visual Studios and then right clicked+Build on it. It does seem that the dll_mpir_gc compiled fine though after trying it just now.

I'm heading home now, but tomorrow I'll recheck everything with fresh eyes.

BrianGladman commented 4 years ago

You have to build lib_mpir_gc (or an optimised version) before you build lib_mpir_cxx since the latter only adds the C++ interface to the MPIR C library (i.e. both libraries are needed for C++). However the DLL contains both the C and the C++ interfaces.

BBlayne commented 4 years ago

Thanks! That worked. It never would have occurred to me that there was a correct order to compile the projects.

BrianGladman commented 4 years ago

It is all explained in the documentation!

BBlayne commented 4 years ago

I mean I looked and I didn't see anything... The README didn't say, at a glance the mpir.pdf file didn't seem like it had instructions either...... Where's the documentation?

BrianGladman commented 4 years ago

I don't mind helping you and I don't mean to be rude but you really didn't look very hard. Even just looking at the Table of Contents in mpir.pdf gets you to "2.4 Building with Microsoft Visual Studio" on page 11. If you want an optimised version of MPIR you need to read it!

BBlayne commented 4 years ago

That's fine, there's stuff I basically don't know very well because of how my university courses were structured.

I basically assumed the pdf after I opened it looked like official documentation from wherever MPIR originated from and not something you added and didn't look past the title page. Although I point out that if you go to page 12 it's definitely not obvious to me what the build order is.

It just says: "Visual Studio will then display a list of individual build projects from which anappropriate version of MPIR can be built. For example, a typical list of projects is: lists them

MPIR can be built either as a static library or as a DLL. A DLL will include both the C and C++ features of MPIR but a static library will include only the C features

so in this case the project: lib_mpir_cxx should also be built to provide the MPIR C++ static library"

Etc. If this in some way implies "Build dll_mpir_gc first" I absolutely still would have had no idea. If there is something about what a DLL is vs a static library is that would imply one of these is needed to be built first, that isn't something I'm aware of. The only thing I know is some projects just a .lib file from a library and a .dll file with your project exe and sometimes you need header files; past that I don't know.

BrianGladman commented 4 years ago

The first paragraph clearly states how the MPIR library is built. The following paragraph then says that if you want the C++ static library you ALSO have to build the lib_mpir_cxx static library. The ALSO here clearly implies that the previous step is a necessary step. If you want to (a) ignore the ALSO, and (b) do things in the opposite order to that given in the description of the build, then you can hardly blame the documentation for this.

But all of this misses the only point I was making. Even if the documentation had included a perfect description of the build process from your point of view, it wouldn't have made any difference since you didn't bother to read it anyway!

BBlayne commented 4 years ago

Right I'm saying I get that, but yeah I do appreciate your help in helping me getting this sorted. Thanks again.

BrianGladman commented 4 years ago

Its good to know its now working for you now. Please do ask again if you run into any problems