gpt4 book ai didi

c++ - 在 osx 上安装 couchnode(couchbase nodejs 客户端)并出现编译错误

转载 作者:太空宇宙 更新时间:2023-11-04 13:49:08 24 4
gpt4 key购买 nike

安装 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但都没有用

欢迎您的评论

最佳答案

有相关错误:“错误:dlopen([...]/app/node_modules/couchbase/prebuilt/win/x64/couchbase_impl.node, 1): 找不到合适的图像”

我能够在 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=

关于c++ - 在 osx 上安装 couchnode(couchbase nodejs 客户端)并出现编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24256448/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com