Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: ‘CAIRO_FORMAT_INVALID’ was not declared in this scope #1067

Closed
vikky1992 opened this issue Dec 25, 2017 · 4 comments
Closed

error: ‘CAIRO_FORMAT_INVALID’ was not declared in this scope #1067

vikky1992 opened this issue Dec 25, 2017 · 4 comments

Comments

@vikky1992
Copy link

This above issue earlier was thrown by the PNG.h file and now its Backend.h.


make: Entering directory /home/vikas/project/nodegm/node_modules/node-canvas/build'
  SOLINK_MODULE(target) Release/obj.target/canvas-postbuild.node
  COPY Release/canvas-postbuild.node
  CXX(target) Release/obj.target/canvas/src/backend/Backend.o
In file included from ../src/backend/Backend.cc:1:0:
../src/backend/Backend.h: In member function ‘virtual cairo_format_t Backend::getFormat()’:
../src/backend/Backend.h:53:49: error: ‘CAIRO_FORMAT_INVALID’ was not declared in this scope
     virtual cairo_format_t getFormat() { return CAIRO_FORMAT_INVALID; }
                                   
../src/backend/Backend.h:53:71: warning: control reaches end of non-void function [-Wreturn-type]
     virtual cairo_format_t getFormat() { return CAIRO_FORMAT_INVALID; }
              
make: *** [Release/obj.target/canvas/src/backend/Backend.o] Error 1
make: Leaving directory /home/vikas/project/nodegm/node_modules/node-canvas/build'
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:285:23)
gyp ERR! stack     at emitTwo (events.js:125:13)
gyp ERR! stack     at ChildProcess.emit (events.js:213:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:197:12)
gyp ERR! System Linux 2.6.32-358.14.1.el6.x86_64
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/vikas/project/nodegm/node_modules/node-canvas
gyp ERR! node -v v8.0.0
gyp ERR! node-gyp -v v3.6.1
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! canvas@2.0.0-alpha.8 install: node-gyp rebuild

Your Environment

  • Version of node-canvas (alpha.8):
  • Environment (CentOs 6.4 Node v 8.0.0):
@suifengfengye
Copy link

suifengfengye commented Jan 22, 2018

Is this problem fixed and release? I have the same problem in version 2.0.0-alpha.9. And I have to publish my project this week. What should I do?

@LinusU
Copy link
Collaborator

LinusU commented Jan 22, 2018

This should be fixed in 2.0.0-alpha.9, are you sure that you are getting the exact same error? Could you paste the output, so we can see which line it is on?

@suifengfengye
Copy link

suifengfengye commented Jan 23, 2018

@LinusU I'm sorry. I'm use "npm install canvas" yesterday, and appear this error. But when I use "npm install canvas@2.0.0-alpha.9"

make: Entering directory /var/kingdee/jarapp/connecterp-charts-nodejs/node_modules/canvas/build'
SOLINK_MODULE(target) Release/obj.target/canvas-postbuild.node
COPY Release/canvas-postbuild.node
CXX(target) Release/obj.target/canvas/src/backend/Backend.o
CXX(target) Release/obj.target/canvas/src/backend/ImageBackend.o
../src/backend/ImageBackend.cc: In member function ‘int32_t ImageBackend::approxBytesPerPixel()’:
../src/backend/ImageBackend.cc:28:3: warning: case value ‘4’ not in enumerated type ‘cairo_format_t {aka _cairo_format}’ [-Wswitch]
case CAIRO_FORMAT_RGB16_565:
^
CXX(target) Release/obj.target/canvas/src/backend/PdfBackend.o
In file included from ../src/backend/PdfBackend.cc:4:0:
/usr/include/libpng12/png.h:2657:31: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" :
^
/usr/include/libpng12/png.h:2665:31: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" :
^
/usr/include/libpng12/png.h:2673:31: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" :
^
CXX(target) Release/obj.target/canvas/src/backend/SvgBackend.o
In file included from ../src/backend/SvgBackend.cc:4:0:
/usr/include/libpng12/png.h:2657:31: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" :
^
/usr/include/libpng12/png.h:2665:31: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" :
^
/usr/include/libpng12/png.h:2673:31: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" :
^
CXX(target) Release/obj.target/canvas/src/Backends.o
CXX(target) Release/obj.target/canvas/src/Canvas.o
In file included from ../src/PNG.h:3:0,
from ../src/Canvas.cc:18:
/usr/include/libpng12/png.h:2657:31: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" :
^
/usr/include/libpng12/png.h:2665:31: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" :
^
/usr/include/libpng12/png.h:2673:31: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" :
^
In file included from ../src/Canvas.cc:18:0:
../src/PNG.h: In function ‘cairo_status_t canvas_write_png(cairo_surface_t*, png_rw_ptr, canvas_png_write_closure_t*)’:
../src/PNG.h:19:31: warning: case label value is less than minimum value for type [enabled by default]
#define CAIRO_FORMAT_INVALID -1
^
../src/PNG.h:200:10: note: in expansion of macro ‘CAIRO_FORMAT_INVALID’
case CAIRO_FORMAT_INVALID:
^
../src/PNG.h:196:5: warning: case value ‘4’ not in enumerated type ‘cairo_format_t {aka _cairo_format}’ [-Wswitch]
case CAIRO_FORMAT_RGB16_565:
^
CXX(target) Release/obj.target/canvas/src/CanvasGradient.o
CXX(target) Release/obj.target/canvas/src/CanvasPattern.o
CXX(target) Release/obj.target/canvas/src/CanvasRenderingContext2d.o
../src/CanvasRenderingContext2d.cc: In static member function ‘static Nan::NAN_METHOD_RETURN_TYPE Context2d::New(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/CanvasRenderingContext2d.cc:525:65: error: invalid conversion from ‘int’ to ‘cairo_format_t {aka _cairo_format}’ [-fpermissive]
else if (!strcmp(*utf8PixelFormat, "RGB16_565")) format = CAIRO_FORMAT_RGB16_565;
^
../src/CanvasRenderingContext2d.cc: In static member function ‘static Nan::NAN_GETTER_RETURN_TYPE Context2d::GetFormat(v8::Localv8::String, Nan::NAN_GETTER_ARGS_TYPE)’:
../src/CanvasRenderingContext2d.cc:558:3: warning: case value ‘4’ not in enumerated type ‘cairo_format_t {aka _cairo_format}’ [-Wswitch]
case CAIRO_FORMAT_RGB16_565: pixelFormatString = "RGB16_565"; break;
^
../src/CanvasRenderingContext2d.cc: In static member function ‘static Nan::NAN_METHOD_RETURN_TYPE Context2d::PutImageData(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/CanvasRenderingContext2d.cc:738:3: warning: case value ‘4’ not in enumerated type ‘cairo_format_t {aka _cairo_format}’ [-Wswitch]
case CAIRO_FORMAT_RGB16_565: {
^
../src/CanvasRenderingContext2d.cc: In static member function ‘static Nan::NAN_METHOD_RETURN_TYPE Context2d::GetImageData(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/CanvasRenderingContext2d.cc:907:3: warning: case value ‘4’ not in enumerated type ‘cairo_format_t {aka _cairo_format}’ [-Wswitch]
case CAIRO_FORMAT_RGB16_565: {
^
make: *** [Release/obj.target/canvas/src/CanvasRenderingContext2d.o] Error 1
make: Leaving directory /var/kingdee/jarapp/connecterp-charts-nodejs/node_modules/canvas/build' gyp ERR! build error gyp ERR! stack Error: makefailed with exit code: 2 gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23) gyp ERR! stack at emitTwo (events.js:125:13) gyp ERR! stack at ChildProcess.emit (events.js:213:7) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12) gyp ERR! System Linux 2.6.32-642.6.2.el6.centos.plus.x86_64 gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /var/kingdee/jarapp/connecterp-charts-nodejs/node_modules/canvas gyp ERR! node -v v8.7.0 gyp ERR! node-gyp -v v3.6.2 gyp ERR! not ok npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! canvas@2.0.0-alpha.9 install:node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the canvas@2.0.0-alpha.9 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-01-23T00_45_04_774Z-debug.log`

Environment

  • Version of node-canvas (alpha.9)
  • Environment (Red Hat 4.4.7-16 Node v 8.7.0 gcc 4.8.2)

Is there any problem with my environment?

@zbjornson
Copy link
Collaborator

@suifengfengye can you try using canvas-prebuilt instead please? CentOS's default package manger ships an ancient version of Cairo (>10 years old) that isn't supported by node-canvas. npm install canvas-prebuilt@next or yarn add canvas-prebuilt@next.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants