我正在尝试通过运行以下命令在MAC上安装"opencv4nodejs“包:
CXXFLAGS=-std=gnu++11 npm i -g opencv4nodejs这给了我以下错误:
/usr/local/lib/node_modules/opencv4nodejs/node_modules/opencv-build/opencv/opencv/modules/highgui/src/window_cocoa.mm:269:25: error: non-constant-expression cannot be narrowed from type 'int' to 'CGFloat' (aka 'double') in initializer list [-Wc++11-narrowing]
NSSize size = { width, height };
^~~~~
/usr/local/lib/node_modules/opencv4nodejs/node_modules/opencv-build/opencv/opencv/modules/highgui/src/window_cocoa.mm:269:25: note: insert an explicit cast to silence this issue
NSSize size = { width, height };
^~~~~
static_cast<CGFloat>( )
/usr/local/lib/node_modules/opencv4nodejs/node_modules/opencv-build/opencv/opencv/modules/highgui/src/window_cocoa.mm:269:32: error: non-constant-expression cannot be narrowed from type 'int' to 'CGFloat' (aka 'double') in initializer list [-Wc++11-narrowing]
NSSize size = { width, height };
^~~~~~
/usr/local/lib/node_modules/opencv4nodejs/node_modules/opencv-build/opencv/opencv/modules/highgui/src/window_cocoa.mm:269:32: note: insert an explicit cast to silence this issue
NSSize size = { width, height };
^~~~~~
static_cast<CGFloat>( )我发现关于-Wno-c++11-narrowing标志的this回答忽略了这个错误。
问题是我不知道如何将该标志传递给npm命令。
我试过了:CXXFLAGS=-std=c++11=-Wno-c++11-narrowing npm i -g opencv4nodejs,但没有成功。
如何将C++标志向下传递给npm命令?
发布于 2020-02-10 04:49:12
命令CXXFLAGS=-std=c++11=-Wno-c++11-narrowing npm i -g opencv4nodejs将CXXFLAGS变量设置为“-std=c++11=-Wno-c++11- command”,并运行npm命令。
但是您并不希望将-std编译器选项设置为“c++11=-Wno-c++11- compiler”-您真正需要的是由空格分隔的两个参数。
问题是,你不能仅仅停留在一个空格中,因为CXXFLAGS=-std=c++11 -Wno-c++11-narrowing ...试图运行一个叫做“-Wno-c++11-收窄”的命令。
解决方案是使用反斜杠对空格进行转义,这样shell就不会将其解释为变量和命令之间的分隔符。
你真正想要的是:
CXXFLAGS=-std=c++11\ -Wno-c++11-narrowing npm i -g opencv4nodejshttps://stackoverflow.com/questions/60107083
复制相似问题