2

我正在尝试为节点 js 构建 hello world c++ 插件。node.js 和 node-gyp 似乎都已成功安装到 redhat linux 中。但是,当我运行“node-gyp configure”时,它给出了以下错误。我未能通过谷歌以及维基页面获得任何有见地的信息。你能请教吗?

我从源代码构建了 python 并进行了自定义安装。并且 libpython2.7.so.1.0 呈现在以下内容中:$PYTHONPATH 以及 $LD_LIBRARY_PATH。node 或 node-gyp 是否会为共享库搜索一个完全不同的环境?

提前致谢。

堆栈错误:

~/examples/node.js/my_node_addon-1[13:14]% node-gyp configure
gyp info it worked if it ends with ok
gyp info using node-gyp\@0.10.10
gyp info using node\@0.10.18 | linux | x64
gyp ERR! configure error
gyp ERR! stack Error: Command failed: python: error while loading shared libraries:      libpython2.7.so.1.0: cannot open shared object file: No such file or directory
gyp ERR! stack
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:637:15)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at maybeClose (child_process.js:735:16)
gyp ERR! stack     at Socket.<anonymous> (child_process.js:948:11)
gyp ERR! stack     at Socket.EventEmitter.emit (events.js:95:17)
gyp ERR! stack     at Pipe.close (net.js:466:12)
gyp ERR! System Linux 2.6.18-194.32.1.el5
gyp ERR! command "node" "/work/dengf/conf/bin/node-gyp" "configure"
gyp ERR! cwd /home/dengf/examples/node.js/my_node_addon
gyp ERR! node -v v0.10.18
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok

但是当我单独运行 python 时,它会很好地加载共享库:

~/examples/node.js/my_node_addon-1[13:14]% python -V
Python 2.7.3

另外,我的 binding.gyp 如下:

{
    'targets': [
        {
            'target_name': 'hello',
            'sources': [ 'src/hello.cc' ],
            'include_dirs': ['/path/to/my/include'],
            'link_settings': {
                'library_dirs': [
                    '/path/to/my/libpython2.7.so.1.0'
                ]
            }
        }
    ]
}
4

1 回答 1

2

终于,经过2天的连续跟踪和调试,我把这个整理好了。但是,我不确定这是否是由于我自定义安装了 Python。我在 ~node_modules/node-gyp/lib/configure.js 中更新了下面的代码(将原始代码更改为第 93 行到第 94 行的注释:

93     // var env = { TERM: 'dumb', PATH: process.env.PATH};
94     var env = process.env;

如果小组中的任何 node.js 专家可以帮助理性地进行上述更改,我将不胜感激?

我还在google group nodejs上发布了这个问题,仅供参考。

再次感谢冯

于 2013-09-19T12:51:02.300 回答