Installing GMP on Windows with cygwin

瘦欲@ 提交于 2019-12-30 05:24:08

问题


I am new to C++ and I have to handle large integers, so I have to install GMP through Cygwin.

Any documentation I can find on installing this already assumes that you know what you are talking about, and I really don't.

Anyway, I got the right .tar or whatever, extracted it properly, and now any website I see says to run ./configure --prefix=${gmp_install}...

What in the world is gmp_install? And what directory do I run configure from? Huh? I can run it from my little Cygwin terminal, but it just says no such file.

Next, I am supposed to type make. From where?

Help...


回答1:


Welcome to StackOverflow (SO).

The source directory of GMP should probably contain the file called configure. This is the script which you have to execute to "configure" the build system in your environment. It means that during configuration Autotools (the build system which is used to build GMP) will gather information about your environment and generate the appropriate makefile. Gathering information includes things like: understanding that you are on Windows, understanding that you are using Cygwin, understanding that your compiler is GCC and its version is x.y.z, and etc. All these steps are important for successful build.

You can specify a lot of different options to this configure script to tweak the configuration process. In your case, you specify the prefix option which determines the installation directory, i.e. the directory where you want the built and ready-to-use GMP distribution to reside. For example:

./configure --prefix=/D/Libraries/GMP

will configure the build system to install the GMP binaries to D:\Libraries\GMP directory.

Assuming that the GMP source directory (the one you extracted from *.tar) is located at say D:\Users\Me\Downloads\GMP, in order to build and install GMP you should do the following:

cd /D/Users/Me/Downloads/GMP
./configure --prefix=/D/Libraries/GMP
make
make install

NOTE: The make command will actually execute the makefile (which was generated by configure script) I've mentioned earlier. This file describes the process of building and installing GMP on your system.

NOTE: ${gmp_install} is nothing, but an environment variable. For instance, you could do:

export gmp_install=/D/Libraries/GMP
./configure --prefix=${gmp_install}

this can be useful, for example, when you have to use the same path in multiple places, and don't want to type it everytime. There are other cases, when this is useful, but for that you'll have to learn more about environment variables, what they are for, and Bash scripting in general. However, all this goes far beyond the answer on your question.

You'll have to spend quite some time to understand all these things and how they fit together, and you'd probably have to ask more questions here on SO as understanding all that stuff for a beginner alone might be very challenging.



来源:https://stackoverflow.com/questions/16049726/installing-gmp-on-windows-with-cygwin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!