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

发布于 2024-11-06 03:24:06 字数 129 浏览 1 评论 0原文

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

I'm trying to connect to Oracle 10.2.0.4 on a remote system from my intel mac running OSX 10.6 snow leopard. I've tried using perl CPAN to install DBD::Oracle (DBI worked ok) but get compilation errors. Could someone provide an easy to follow guide?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

粉红×色少女 2024-11-13 03:24:06

在 mac 上安装 perl 来与 oracle 很好地配合是有点痛苦 - 一旦它运行起来就很棒了,让它运行起来有点令人沮丧..

下面的内容对我来说在一些不同的 intel mac 上工作,很可能那里是多余的步骤,对于其他平台来说可能不会相同。

这将需要使用 shell、root 用户和一些 CPANing - 没什么太繁琐的

首先为 oracle pap 创建一个目录 - 库、即时客户端等

sudo mkdir /usr/oracle_instantClient64

oracle 到上述目录

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

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

以下目录被硬编码到 oracle 即时客户端中 - 天知道为什么 - 所以需要创建并符号链接它

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/build 目录 - 如果您使用 CPAN 的自动配置'二如果

cd ~/.cpan/build

你没有自动配置,你可以在 CPAN 中使用以下命令找到你的构建目录

o conf build_dir

一旦在构建目录中查找刚刚创建的 DBD::Oracle 目录(它将被称为类似 DBD-Oracle- 1.28-?)并进入它。

现在我们需要切换到root用户。 osx 中默认未启用 Root - 有关启用的详细信息,请参阅 Apple 网站 上的这篇文章

以 root 身份登录后,我们需要为 root 设置上述环境变量:

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

现在,当仍然以 root 身份登录时,我们需要运行模块的 makefile,然后 make,然后安装

perl Makefile.pl
make
make install

假设一切正常,没有错误从 root 注销:我们是 DBD 向上!如果这不起作用,那么是时候在 google 上搜索您所看到的任何错误了

现在只需安装 DBI 模块

sudo perl -MCPAN -e shell
install DBI

现在您已准备就绪 - 享受您的 perly oracley 新生活

来自 user852637 的附加信息:

  1. 对此的更正步骤

    perl Makefile.pl
    制作
    安装
    

    最后一步应该是make install

  2. 在make的时候,可能会遇到错误看起来像:

    <块引用>

    lipo:无法打开输入文件:/var/tmp//ccIevTzM.out(没有这样的文件或目录)

    要纠正此问题,您必须编辑在“perl Makefile.pl”步骤之后创建的文件“Makefile”,并删除所有出现的以下文本:

    <前><代码>-arch ppc

    这将消除错误。

  3. 在安装 DBI 模块期间,会发生与 (2.) 中描述的相同错误。您必须编辑在 perl Makefile.pl 步骤之后创建的 Makefile,并删除所有出现的以下文本:

    <前><代码>-arch ppc

Getting a mac install of perl to play nicely with oracle is a bit of a pain - once it's running it is fantastic, getting it running is a little frustrating..

The below has worked for me on a few different intel macs, there could well be superfluous steps in there and it is likely not going to be the same for other platforms.

This will require use of shell, the root user and a bit of CPANing - nothing too onerous

First off create a directory for the oracle pap - libraries, instant client etc

sudo mkdir /usr/oracle_instantClient64

Download and extract all 64 bit instant client packages from oracle to the above directory

Create a symlink within that directory for one of the files in there

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

The following dir is hardcoded into the oracle instant client - god knows why - so need to create and symlink it

sudo mkdir -p /b/227/rdbms/
sudo cd /b/227/rdbms/
sudo ln -s /usr/oracle_instantClient64/ lib

Need to add a couple of environment variables, so edit /etc/profile and add them so they exist for all users:

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

Now try and install DBD::Oracle through CPAN - this will fail, but it means any dependencies will be downloaded and it retrieves the module for us

sudo perl -MCPAN -e shell
install DBD::Oracle

When this fails exit CPAN and head to your .cpan/build dir - if you used automatic config of CPAN it'll be

cd ~/.cpan/build

if you didn't auto configure you can find your build directory with the following command in CPAN

o conf build_dir

Once in the build dir look for the DBD::Oracle dir which has just been created (it'll be called something like DBD-Oracle-1.28-?) and cd into it.

Now we need to switch to the root user. Root isn't enabled as default in osx - for details on enabling see this post on the apple website

Once logged in as root we need to set the above environment variables for root:

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

Now while still logged in as root we need to run the makefile for the module, then make, then install

perl Makefile.pl
make
make install

Assuming that all worked without error log out of root: we're DBD'd up! If this didn't work it's time to bust out google on whatever errors you're seeing

Now just to install the DBI module

sudo perl -MCPAN -e shell
install DBI

Now you're all set - enjoy your perly oracley new life

Additional info from user852637:

  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 
    
岁月流歌 2024-11-13 03:24:06

看起来随着 XCode4 的更改(删除 PPC arch 支持),Perl 安装在任何 10.6.X 更新中都没有更新以删除 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 将是正确的。

It looks with the XCode4 change (removal of PPC arch support) the Perl installation was not updated in any of the 10.6.X updates to also remove PPC binaries (probably because Rosetta is still present).

Because of this, the configuration files retain "-arch ppc" causing all CPAN module compiles with C libraries to fail because MakeMaker's output Makefile contains -arch ppc.

To fix this one can edit the following file:

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

at line 1219 you'll see:

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

change that to:

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

Once you do this the generated Makefile will be correct.

撕心裂肺的伤痛 2024-11-13 03:24:06

这是一组很棒的说明。我对潜在的“陷阱”还有一些其他评论。

  1. 此步骤的更正

    perl Makefile.pl
    制作
    安装
    

    最后一步应该是make install

  2. 在make的时候,可能会遇到错误看起来像:

    <块引用>

    lipo:无法打开输入文件:/var/tmp//ccIevTzM.out(没有这样的文件或目录)

    要纠正此问题,您必须编辑在“perl Makefile.pl”步骤之后创建的文件“Makefile”,并删除所有出现的以下文本:

    <前><代码>-arch ppc

    这将消除错误。

  3. 在安装 DBI 模块期间,会发生与 (2.) 中描述的相同错误。您必须编辑在 perl Makefile.pl 步骤之后创建的 Makefile,并删除所有出现的以下文本:

    <前><代码>-arch ppc

These are a great set of instructions. I have a few other comments about potential "gotchas".

  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 
    
平定天下 2024-11-13 03:24:06

似乎“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 驱动程序版本 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” “ 参考。

It seems as though the "Perl MakeFile.pl" command is not finding the version of Perl correctly and I get this error message:

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.

If I force the version number like this:

perl MakeFile.pl -V 10.2.0.4

It completes, but I receive the error message when running "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

I realize this is because of the "-arch ppc" argument that needs to be removed from Makefile, but even after removal the removal of all 32-bit references, I still saw the error message.

Running 10.6.8 Snow Leopard with Oracle Driver version 10.2.0.4

I found that the key to this issue was making sure that MakeFile.pl could find the Oracle version.

The problem I ran into was that Safari was downloading the zip files from Oracle.com, but unzipping them and somehow corrupting the library.

Instead, I used a different browser and downloaded all the zip files into one directory. Then I ran the following tar commands:

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

The copy all the contents in the folder "instantclient_10_2" to $ORACLE_HOME (set previously)

sudo cp -R instantclient_10_2/* $ORACLE_HOME

Also, I did not need to edit the Makefile generated by the MakeFile.pl script to remove the "-arch ppc" references.

ぃ弥猫深巷。 2024-11-13 03:24:06

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

不要使用 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 .

You should not recreate on your machine the same directory structure as of the client libraries packager.

Don't do mkdir -p /b/227/rdbms/

Use MacOSX library header management tools: otool and install_name_tool

For instance, I have updated the library headers to my deployment architecture:

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)

Check all files that come with the Oracle instantclient libraries and fix the path of all dependent libs

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

Then, you link your dynamic libraries to the place they're supposed to be.

And you can avoid using that export DYLD_LIBRARY_PATH because you know how to setup your system

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 .
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文