【问题标题】:How to install DBI and other modules on msysgit (on Windows 7)?如何在 msysgit(在 Windows 7 上)上安装 DBI 和其他模块?
【发布时间】:2016-11-30 15:56:59
【问题描述】:

我正在尝试在我的 Windows 7 机器上安装 DBI perl 模块,使用 Git for Windows,即。 msysgit,以及它附带的 perl 版本。

我已经能够安装一些其他 perl 模块,但是当我尝试安装 DBI(通过 perl -MCPAN -e "install DBI")时,构建过程会出现以下错误:

"/usr/bin/perl.exe" "/usr/share/perl5/core_perl/ExtUtils/xsubpp"  -typemap "/usr/share/perl5/core_perl/ExtUtils/typemap" -typemap "typemap"  Perl.xs > Perl.xsc && mv Perl.xsc Perl.c

gcc -c   -DPERL_USE_SAFE_PUTENV -U__STRICT_ANSI__ -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -D_FORTIFY_SOURCE=2 -DUSEIMPORTLIB -march=x86-64 -mtune=generic -O2 -pipe   -DVERSION=\"1.636\" -DXS_VERSION=\"1.636\"  "-I/usr/lib/perl5/core_perl/CORE"  -W -Wall -Wpointer-arith -Wbad-function-cast -Wno-comment -Wno-sign-compare -Wno-cast-qual -Wmissing-noreturn -Wno-unused-parameter Perl.c

In file included from DBIXS.h:23:0,
             from Perl.xs:7:
C:/git-sdk-64/usr/lib/perl5/core_perl/CORE/perl.h:805:25: fatal error: sys/wait.h: No such file or directory
      #   include <sys/wait.h>
                     ^
compilation terminated.
make: *** [Makefile:627: Perl.o] Error 1
 TIMB/DBI-1.636.tar.gz
 /usr/bin/make -- NOT OK

我在尝试安装 Text::CSV_XS 时遇到类似错误。

根据我在其他地方读到的内容,我假设我在构建环境中遗漏了一些东西。我已经安装了所有 development metapackages mentioned on the msysgit documentation 没有任何运气。

我不反对在不使用 cpan 的情况下以某种方式构建模块,但我不知道如何解决我遇到的错误,更不用说构建新的东西了。有什么建议吗?

【问题讨论】:

  • msysgit 提供了一个包,可以通过 pacman 为 DBI 安装:pacman -S perl-DBI 但是,这并不能解决更广泛的缺失问题,阻止 cpan 安装其他模块,如 Text::CSV_XS 或其他任何模块我以后需要。
  • msysgit 好像没有提供完整的构建环境。
  • 您是否尝试过使用Cygwin?我在那里安装了 DBI 和 Text::CSV_XS,没有任何问题。
  • 或者试试 Active Perl,它有 ppm,perl 包管理器。它下载预构建的二进制文件,而不是尝试编译某些模块使用的 C 代码 (XS)..
  • 或者使用 Strawberry Perl:ActiveState Perl 和 Strawberry 都有一个完整的工作 CPAN 客户端,允许您使用 MSYS 编译几乎任何东西。此外,Strawberry 还预装了许多模块,例如 DBI 和您最喜欢的数据库驱动程序。

标签: perl cpan dbi msysgit


【解决方案1】:

我安装了 Git-for-Windows SDK 和 Strawberry Perl。我使用这个 bash 函数(你的 Strawberry Perl 安装目录可能不同):

#!/bin/bash
#echo sperl
function sperl {
    local pargs=("$@") PP="/c/Strawberry" # PP="$HOME/SwPerl64/ZIP"
    (
    export PATH="$PP/c/bin:$PP/perl/site/bin:$PP/perl/bin:$PATH"
    perl "${pargs[@]}"
    )
}

我的路径中也有类似的东西sperl.sh

#!/bin/bash
export PATH="$PATH:$HOME/bin"
#
function sperl {
    local pargs=("$@") PP="/c/Strawberry" # PP="$HOME/SwPerl64/ZIP"
    (
    export PATH="$PP/c/bin:$PP/perl/site/bin:$PP/perl/bin:$PATH"
    perl "${pargs[@]}"
    )
}
#
sperl "$@"

这允许这样的脚本:

#!/bin/env sperl.sh
use DBI;
use strict;
use warnings;
print "Hello World!\n";

【讨论】:

    【解决方案2】:

    mysysgit 不提供完整的构建环境。因此,最好的解决方案是安装另一个版本的 Perl(例如草莓 Perl 或 Active Perl)并更改路径,以便 mysysgit 使用该 perl 而不是内置的。

    【讨论】:

      猜你喜欢
      • 2014-05-03
      • 1970-01-01
      • 1970-01-01
      • 2013-06-22
      • 2016-11-30
      • 2012-11-11
      • 1970-01-01
      • 2015-11-10
      • 1970-01-01
      相关资源
      最近更新 更多