如何在OSX Snow Leopard 10.6上安装Perl DBD::Oracle?

3

我正在尝试从我的英特尔mac运行OSX 10.6 snow leopard连接到远程系统上的Oracle 10.2.0.4。我尝试使用Perl CPAN安装DBD :: Oracle(DBI正常工作),但出现编译错误。是否有人可以提供一个易于遵循的指南?


如果您按照nickistat的方法并使其正常工作,是否介意将结果和任何更改发送至cpan dot org上的martin邮箱?然后我会将其添加到DBD::Oracle的README.macosx.txt文件中。了解您的确切Mac处理器和版本详细信息将非常有用。 - bohica
5个回答

4

看起来由于XCode4的变化(删除PPC架构支持),在10.6.X更新中Perl安装未被更新以删除PPC二进制文件(可能是因为Rosetta仍然存在)。

因此,配置文件仍保留“-arch ppc”,导致所有使用C库编译的CPAN模块编译失败,因为MakeMaker的输出Makefile包含“-arch ppc”。

要解决此问题,可以编辑以下文件:

/System/Library/Perl/5.10.0/darwin-thread-multi-2level/Config_heavy.pl  

在第1219行你会看到:

$archflags = exists($ENV{ARCHFLAGS}) ? $ENV{ARCHFLAGS} : '-arch x86_64 -arch i386 -arch ppc';

将其改为:

更改为:

$archflags = exists($ENV{ARCHFLAGS}) ? $ENV{ARCHFLAGS} : '-arch x86_64 -arch i386';

完成此操作后,生成的Makefile将正确无误。


谢谢!我已经寻找了一段时间一个好的解决方案。 - gaige

4

将mac上的perl与oracle协调起来有点棘手-一旦运行起来,它就非常棒,但是让它运行起来有点令人沮丧。

以下内容在几个不同的Intel Macs上为我工作过,其中可能有多余的步骤,并且对于其他平台可能不会相同。

这将需要使用shell、root用户和一些CPAN - 没有太大的负担。

首先创建一个目录,用于存放Oracle pap - 库、即时客户端等。

sudo mkdir /usr/oracle_instantClient64

Oracle下载并提取所有64位即时客户端软件包到上述目录中。

在该目录中为其中一个文件创建符号链接。

sudo cd /usr/oracle_instantClient64
sudo ln -s /usr/oracle_instantClient64/libclntsh.dylib.10.1 libclntsh.dylib

以下目录是硬编码在Oracle Instant Client中的 - 谁知道为什么 - 因此需要创建并建立符号链接。
sudo mkdir -p /b/227/rdbms/
sudo cd /b/227/rdbms/
sudo ln -s /usr/oracle_instantClient64/ lib

需要添加一些环境变量,因此请编辑 /etc/profile 并添加它们,以便所有用户都可以使用:

export ORACLE_HOME=/usr/oracle_instantClient64
export DYLD_LIBRARY_PATH=/usr/oracle_instantClient64

现在尝试通过CPAN安装DBD::Oracle - 这将失败,但它意味着任何依赖项将被下载并为我们检索模块。
sudo perl -MCPAN -e shell
install DBD::Oracle

如果CPAN安装失败,请退出CPAN并转到您的.cpan/build目录 - 如果您使用的是自动配置的CPAN,则该目录将为

cd ~/.cpan/build

如果您没有自动配置,可以在CPAN中使用以下命令找到您的构建目录。
o conf build_dir

一旦在构建目录中寻找刚创建的DBD::Oracle目录(名称类似于DBD-Oracle-1.28-?),然后进入该目录。
现在我们需要切换到root用户。osx默认情况下未启用root用户 - 有关启用的详细信息,请参见苹果网站上的此帖子。
一旦以root身份登录,我们需要为root设置上述环境变量。
export ORACLE_HOME=/usr/oracle_instantClient64
export DYLD_LIBRARY_PATH=/usr/oracle_instantClient64

现在,仍然以root用户身份登录,我们需要运行模块的makefile,然后进行编译和安装。
perl Makefile.pl
make
make install

假设一切顺利,没有错误,退出root用户:我们已经准备好使用DBD了!如果出现错误,请使用谷歌搜索解决方案。
现在只需要安装DBI模块。
sudo perl -MCPAN -e shell
install DBI

现在你已经准备好了 - 享受你珍珠般的全新生活吧。
用户852637提供的额外信息:
  1. Correction to this step

    perl Makefile.pl
    make
    install
    

    The last step should be make install

  2. During make, you may encounter an error that looks like :

    lipo: can't open input file: /var/tmp//ccIevTzM.out (No such file or directory)

    To correct this you must edit the file "Makefile" created after the "perl Makefile.pl" step and remove all occurrences of the following text :

    -arch ppc 
    

    This will eliminate the error.

  3. The same error described in (2.) will occur during the installation of the DBI module. You must edit the Makefile created after the perl Makefile.pl step and remove all occurrences of the following text :

    -arch ppc 
    

听起来非常有用,我注意到在readme.macosx.txt中没有关于10.6版本的DBD::Oracle的内容。你介意我把它添加到DBD::Oracle吗? - bohica
加油 - 我已经在以下设备上运行了这个进程:Macmini3,1;MacPro1,1和一台旧的MacbookPro(不确定型号标识符是什么) - beresfordt
你可以使用 "look DBD::Oracle" 代替退出 CPAN shell,查找构建目录并进入其目录的步骤。 - hobbs
最好将这种安装放在 /应用程序 中而不是 /用户 中,考虑一下系统升级的问题... - user123664
已添加到DBD::Oracle的readme.macosx.txt中,应该在1.29_1中。 - bohica

3

这是一组非常好的指令。我有一些关于潜在“陷阱”的其他评论。

  1. Correction to this step

    perl Makefile.pl
    make
    install
    

    The last step should be make install

  2. During make, you may encounter an error that looks like :

    lipo: can't open input file: /var/tmp//ccIevTzM.out (No such file or directory)

    To correct this you must edit the file "Makefile" created after the "perl Makefile.pl" step and remove all occurrences of the following text :

    -arch ppc 
    

    This will eliminate the error.

  3. The same error described in (2.) will occur during the installation of the DBI module. You must edit the Makefile created after the perl Makefile.pl step and remove all occurrences of the following text :

    -arch ppc 
    

1

看起来 "Perl MakeFile.pl" 命令没有正确找到 Perl 的版本,我收到了这个错误信息:

bash-3.2# perl Makefile.PL 
Multiple copies of Driver.xst found in: /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBI/ /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level/auto/DBI/ at Makefile.PL line 37
Using DBI 1.616 (for perl 5.010000 on darwin-thread-multi-2level) installed in /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBI/

Configuring DBD::Oracle for perl 5.010000 on darwin (darwin-thread-multi-2level)

Remember to actually *READ* the README file! Especially if you have any problems.

Installing on a darwin, Ver#10.0
Using Oracle in /usr/oracle_instantClient64
Can't find sqlplus. Pity, it would have helped.
I'm having trouble finding your Oracle version number... trying harder

WARNING: I could not determine Oracle client version so I'll just
default to version 8.0.0.0. Some features of DBD::Oracle may not work.
Oracle version based logic in Makefile.PL may produce erroneous results.
You can use "perl Makefile.PL -V X.Y.Z" to specify a your client version.

Oracle version 8.0.0.0 (8.0)
DBD::Oracle no longer supports Oracle client versions before 9.2 
 Try a version before 1.25 for 9 and 1.18 for 8! at Makefile.PL line 175.

I've triple checked that I've downloaded and installed the proper 64-bit drivers from Oracle. I also checked to make sure that I'm running 64-bit Perl.

如果我像这样强制指定版本号:
perl MakeFile.pl -V 10.2.0.4

编译完成,但在运行“make”时收到错误消息:

Oracle.c:2267: error: ‘SQLT_BIN’ undeclared (first use in this function)
Oracle.c:2277: error: ‘SQLCS_NCHAR’ undeclared (first use in this function)
Oracle.c:2281: error: ‘SQLT_INT’ undeclared (first use in this function)
Oracle.c:2283: error: ‘OCI_FETCH_PRIOR’ undeclared (first use in this function)
Oracle.c:2287: error: ‘OCI_FETCH_NEXT’ undeclared (first use in this function)
lipo: can't open input file: /var/tmp//ccyIFLPN.out (No such file or directory)
make: *** [Oracle.o] Error 1

我意识到这是由于需要从Makefile中删除“-arch ppc”参数,但即使删除了所有32位引用,我仍然看到错误消息。

使用Oracle Driver版本10.2.0.4运行10.6.8 Snow Leopard

我发现解决此问题的关键是确保MakeFile.pl可以找到Oracle版本。

我遇到的问题是Safari从Oracle.com下载zip文件,但解压缩它们并以某种方式破坏库。

相反,我使用了不同的浏览器,并将所有zip文件下载到一个目录中。 然后我运行了以下tar命令:

tar -xf instantclient-basic-10.2.0.4.0-macosx-x64.zip 
tar -xf instantclient-sdk-10.2.0.4.0-macosx-x64.zip 
tar -xf instantclient-sqlplus-10.2.0.4.0-macosx-x64.zip

将“instantclient_10_2”文件夹中的所有内容复制到先前设置的$ORACLE_HOME目录中

sudo cp -R instantclient_10_2/* $ORACLE_HOME

此外,我不需要编辑由MakeFile.pl脚本生成的Makefile文件以删除“-arch ppc”引用。

1

请不要在您的计算机上重新创建与客户端库包装程序相同的目录结构。

不要执行 mkdir -p /b/227/rdbms/

使用MacOSX库头文件管理工具: otoolinstall_name_tool

例如,我已将库头文件更新为我的部署架构:

otool -L /usr/oracle_instantclient/11.2.0.3.0-64-bit/libclntsh.dylib.11.1
/usr/oracle_instantclient/11.2.0.3.0-64-bit/libclntsh.dylib.11.1:
    /ade/b/2649109290/oracle/rdbms/lib/libclntsh.dylib.11.1 (compatibility version 0.0.0, current version 0.0.0)
    /ade/b/2649109290/oracle/ldap/lib/libnnz11.dylib (compatibility version 0.0.0, current version 0.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)

install_name_tool -id /usr/oracle_instantclient/11.2.0.3.0-64-bit/libclntsh.dylib.11.1 \
              -change /ade/b/2649109290/oracle/ldap/lib/libnnz11.dylib /usr/oracle_instantclient/11.2.0.3.0-64-bit/libnnz11.dylib /usr/oracle_instantclient/11.2.0.3.0-64-bit/libclntsh.dylib.11.1


otool -L /usr/oracle_instantclient/11.2.0.3.0-64-bit/libclntsh.dylib.11.1
/usr/oracle_instantclient/11.2.0.3.0-64-bit/libclntsh.dylib.11.1:
    /usr/oracle_instantclient/11.2.0.3.0-64-bit/libclntsh.dylib.11.1 (compatibility version 0.0.0, current version 0.0.0)
    /usr/oracle_instantclient/11.2.0.3.0-64-bit/libnnz11.dylib (compatibility version 0.0.0, current version 0.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)

检查所有Oracle instantclient库所附带的文件,并修复所有依赖库的路径。
otool -L adrci
otool -L genezi
otool -L libclntsh.dylib.11.1
otool -L libheteroxa11.dylib
otool -L libnnz11.dylib
otool -L libocci.dylib.11.1
otool -L libociei.dylib
otool -L libocijdbc11.dylib
otool -L libsqlplus.dylib
otool -L libsqlplusic.dylib
otool -L sqlplus
otool -L uidrvci

然后,您将动态库链接到它们应该在的位置。
您可以避免使用 export DYLD_LIBRARY_PATH,因为您知道如何设置系统。
cd /usr/lib
ln -s ../oracle_instantclient/11.2.0.3.0-64-bit/libclntsh.dylib.11.1 .
ln -s ../oracle_instantclient/11.2.0.3.0-64-bit/libclntsh.dylib.11.1 libclntsh.dylib
ln -s ../oracle_instantclient/11.2.0.3.0-64-bit/libheteroxa11.dylib .
ln -s ../oracle_instantclient/11.2.0.3.0-64-bit/libnnz11.dylib .
ln -s ../oracle_instantclient/11.2.0.3.0-64-bit/libocci.dylib.11.1 .
ln -s ../oracle_instantclient/11.2.0.3.0-64-bit/libocci.dylib.11.1 libocci.dylib
ln -s ../oracle_instantclient/11.2.0.3.0-64-bit/libociei.dylib .
ln -s ../oracle_instantclient/11.2.0.3.0-64-bit/libocijdbc11.dylib .
ln -s ../oracle_instantclient/11.2.0.3.0-64-bit/libsqlplus.dylib .
ln -s ../oracle_instantclient/11.2.0.3.0-64-bit/libsqlplusic.dylib .

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接