安装couchnode(couchbase nodejs客户端)与osx上的编译错误

时间:2014-06-17 05:39:50

标签: c++ gcc couchbase node-gyp couchnode

安装了libcouchbase后,我执行了

sudo npm install couchbase

报告错误:

npm WARN cannot run in wd couchbase@1.2.4 (node-gyp rebuild 2> builderror.log) || (exit 0) (wd=/Users/mymac/node_modules/couchbase)

然后我去了node_modules / couchbase并执行了

npm install

输出了日志错误:

../deps/lcb/src/compat.c:194:36: warning: missing field 'v' initializer [-Wmissing-field-initializers]
    struct lcb_create_st cst = { 0 };
                                   ^
1 warning generated.
../src/logger.h: In instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]':
../src/logger.h:74:   instantiated from here
../src/logger.h:74: error: explicit instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]' but no definition available
../src/logger.h: In instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]':
../src/logger.h:74:   instantiated from here
../src/logger.h:74: error: explicit instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]' but no definition available
../src/logger.h: In instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]':
../src/logger.h:74:   instantiated from here
../src/logger.h:74: error: explicit instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]' but no definition available
../src/logger.h: In instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]':
../src/logger.h:74:   instantiated from here
../src/logger.h:74: error: explicit instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]' but no definition available
make: *** [Release/obj.target/couchbase_impl/src/couchbase_impl.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:807:12)
gyp ERR! System Darwin 12.5.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/couchbase
gyp ERR! node -v v0.10.28
gyp ERR! node-gyp -v v0.13.0
gyp ERR! not ok 

看起来像node-gyp无法正确编译源代码

如果我使用代码

 var couchbase = require('couchbase');
 var db = new couchbase.Connection({
     bucket: "default"

 },
 function(err) {
     if (err) throw err;
     db.set('testdoc1', {
         name: 'Frank1'
     }, function(err, result) {
         if (err) throw err;
         db.get('testdoc1', function(err, result) {
             if (err) throw err;
             console.log(result.value);
             // {name: Frank}
         });
     });
 });

控制台报告

Users/mymac/node_modules/couchbase/lib/binding.js:17
      throw e;
            ^
Error: dlopen(/Users/mymac/node_modules/couchbase/prebuilt/win/x64/couchbase_impl.node, 1): no suitable image found.  Did find:
    /Users/mymac/node_modules/couchbase/prebuilt/win/x64/couchbase_impl.node: unknown file type, first eight bytes: 0x4D 0x5A 0x90 0x00 0x03 0x00 0x00 0x00
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at bindings (/Users/mymac/node_modules/couchbase/node_modules/bindings/bindings.js:74:15)
    at tryLoadBinding (/Users/mymac/node_modules/couchbase/lib/binding.js:13:31)
    at Object.<anonymous> (/Users/mymac/node_modules/couchbase/lib/binding.js:31:17)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)

找不到正确的couchbase_impl.node(没什么)

enter image description here

因此它会预先构建并获得错误的平台版本

/Users/mymac/node_modules/couchbase/prebuilt/win/x64/couchbase_impl.node

我尝试在centos,ubuntu上安装couchnode,甚至1年前在osx相同的mac上安装,没有任何问题。

我不确定在做其他工作时我是否已将某些/配置(例如gcc)更改为clang,是否会影响此操作?

我试过

export CC=gcc
export CXX=gcc
export CXXFLAGS=-mmacosx-version-min=10.8

export CC=clang
export CXX=clang
export CXXFLAGS=-mmacosx-version-min=10.8

并重新安装couchnode 但没有一个工作

您的评论欢迎

1 个答案:

答案 0 :(得分:0)

有相关错误:&#34;错误:dlopen([...] / app / node_modules / couchbase / prebuilt / win / x64 / couchbase_impl.node,1):找不到合适的图片&#34;

我能够解决这个问题,在OS X 10.9.5上使用xcode 6.0.1

安装libcouchbase的新副本:

$ brew install libcouchbase

这会将libcouchbase安装到/usr/local/Cellar/libcouchbase/2.4.1(或当前的任何版本)。 接下来通过npm

安装Node-SDK
$ npm install --couchbase-root=/usr/local/Cellar/libcouchbase/2.4.1 couchbase

看起来在OS X上安装时需要声明--couchbase-root =