简体   繁体   English

使用cygwin在Windows上安装GMP

[英]Installing GMP on Windows with cygwin

I am new to C++ and I have to handle large integers, so I have to install GMP through Cygwin. 我是C ++的新手,必须处理大整数,因此必须通过Cygwin安装GMP。

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} ... 无论如何,我找到了正确的.tar或任何名称,可以正确地提取它,现在我看到的任何网站都说可以运行./configure --prefix=${gmp_install} ...

What in the world is gmp_install ? gmp_installgmp_install And what directory do I run configure from? 从哪个目录运行configure Huh? 咦? I can run it from my little Cygwin terminal, but it just says no such file. 我可以从我的Cygwin小终端上运行它,但它只说没有这样的文件。

Next, I am supposed to type make . 接下来,我应该键入make From where? 从哪里?

Help... 救命...

Welcome to StackOverflow (SO). 欢迎使用StackOverflow(SO)。

The source directory of GMP should probably contain the file called configure . GMP的源目录可能应该包含名为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 . 这意味着在配置过程中, Autotools (用于构建GMP的构建系统)将收集有关您的环境的信息并生成适当的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 xyz, and etc. All these steps are important for successful build. 收集信息包括以下内容:了解您在Windows上,了解您正在使用Cygwin,了解您的编译器是GCC并且其版本是xyz,等等。所有这些步骤对于成功构建都很重要。

You can specify a lot of different options to this configure script to tweak the configuration process. 您可以为此configure脚本指定很多不同的选项,以调整配置过程。 In your case, you specify the prefix option which determines the installation directory, ie the directory where you want the built and ready-to-use GMP distribution to reside. 在您的情况下,您可以指定prefix选项来确定安装目录,即要使已构建的即用型GMP发行版驻留的目录。 For example: 例如:

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

will configure the build system to install the GMP binaries to D:\\Libraries\\GMP directory. 将配置构建系统以将GMP二进制文件安装到D:\\Libraries\\GMP目录。

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: 假设GMP源目录(从*.tar提取的目录)位于D:\\Users\\Me\\Downloads\\GMP ,为了构建和安装GMP,您应该执行以下操作:

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. 注意: make命令实际上将执行我前面提到的makefile (由configure脚本生成)。 This file describes the process of building and installing GMP on your system. 该文件描述了在系统上构建和安装GMP的过程。

NOTE: ${gmp_install} is nothing, but an environment variable. 注意: ${gmp_install}只是环境变量。 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. 在其他情况下,这很有用,但是为此,您必须了解有关环境变量 ,它们的用途以及一般Bash脚本的更多信息。 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. 您将不得不花一些时间来理解所有这些内容以及它们如何组合在一起,并且您可能不得不在SO上提出更多问题,因为仅对初学者而言,理解所有这些内容可能会非常具有挑战性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM