简体   繁体   English

如何在带有Strawberry的Windows上编译Perl模块?

[英]How do I compile a Perl module on Windows with Strawberry?

This is more an open discussion and a conclusion than a real question, hoping it can help someone sometime. 与其说是一个真实的问题,不如说是一个开放的讨论和结论,希望它能在某个时候为某人提供帮助。

I was looking on how to make Perl module on an Internet disconnected server (otherwise the answer is quite simple: use cpan ), so the only option I have is to manually compile the modules downloaded from the Internet (CPAN or others) directly on the server. 我一直在研究如何在Internet断开连接的服务器上制作Perl模块(否则答案很简单:使用cpan ),所以我唯一的选择是直接在Internet上手动编译从Internet下载的模块(CPAN或其他)。服务器。

The problem was that, on a standard Windows server, there is no compiler. 问题是,在标准Windows服务器上,没有编译器。 So how do I make the modules? 那么我该如何制作模块呢?

If you look in your Strawberry Perl installation folder you will see a number of useful utilities, including the compilers cpp.exe , c++.exe , gcc.exe and make utilities gmake.exe and dmake.exe . 如果您在Strawberry Perl安装文件夹中查找,将会看到许多有用的实用程序,包括编译器cpp.exec++.exegcc.exe以及make实用程序gmake.exedmake.exe

dmake and gcc together support the use of cpan on your installation, and cpanm is available as well. dmakegcc一起支持在您的安装中使用cpan ,也可以使用cpanm

For information on the general process of installing a module, take a look at perlmodinstall 有关安装模块的一般过程的信息,请查看perlmodinstall

Strawberry Perl includes the necessary compiler environment in the default installation, so compiling modules is no problem. Strawberry Perl在默认安装中包括必需的编译器环境,因此编译模块没有问题。

As for installing modules in an offline environment, I am highly partial to using cpanmini . 至于在离线环境中安装模块,我非常cpanmini使用cpanmini Basically, you create a minimal mirror of all of CPAN using a machine with internet access, then throw that onto your offline machine. 基本上,您可以使用具有互联网访问权限的计算机创建所有CPAN的最小镜像,然后将其扔到离线计算机上。 Change the cpan program's settings to point to this local mirror. 更改cpan程序的设置以指向此本地镜像。 Now you can install nearly any module just like normal with cpan . 现在,您几乎可以像通常使用cpan一样安装任何模块。

It may seem like overkill, but it is really very simple. 可能看起来有些过分,但这确实非常简单。 The CPAN mirror takes up only about 2GB of space, which is nothing these days. CPAN镜像仅占用约2GB的空间,这些天来已不算什么。 You can put it on a USB stick, DVD, or whatever. 您可以将其放在USB记忆棒,DVD或其他任何东西上。 And it is a once-for-all solution--the next time you want to install a module, it is already there. 这是一个万能的解决方案-下次您要安装模块时,它已经存在。

Guys behind Strawberry were smart by packaging among with Perl binaries all you'll need under the <Strawberry install dir>\\c\\bin directory. 通过将Perl二进制文件打包在<Strawberry install dir>\\c\\bin目录下,您将需要的所有Perl二进制文件打包在一起,草莓背后的家伙很聪明。

Then, to compile a Perl module offline directly on a Windows server, the process is quite simple : 然后,要直接在Windows服务器上离线编译Perl模块,过程非常简单:

  1. Download the module .tar.gz file 下载模块.tar.gz文件
  2. Uncompress it 解压缩
  3. Open a cmd in the module directory 在模块目录中打开一个cmd
  4. Type perl Makefile.PL 键入perl Makefile.PL
  5. Type dmake , look if there is no error 输入dmake ,看看是否没有错误
  6. Type dmake test , look if there is no error 输入dmake test ,看是否没有错误
  7. Type dmake install , look if there is no error 输入dmake install ,看是否没有错误

And you should be ok ! 而且你应该没事!

Don't hesitate to complete this article or to ask your questions in order to improve it. 请毫不犹豫地完成本文或提出您的问题以进行改进。

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

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