Can't build a nodejs addon that links to IM x86 Windows

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
josh3736
Posts: 8
Joined: 2013-07-12T12:42:16-07:00
Authentication code: 6789

Can't build a nodejs addon that links to IM x86 Windows

Post by josh3736 »

Trying to build node-imagemagick-native on a Windows 7 x64 box, targeting x86.

ImageMagick's definition of ssize_t conflicts with libuv's definition.

magick-baseconfig.h

Code: Select all

#if !defined(ssize_t) && !defined(__MINGW32__) && !defined(__MINGW64__)
#if defined(_WIN64) 
typedef __int64 ssize_t;
#else
typedef long ssize_t;
#endif
#endif
uv-win.h

Code: Select all

#if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED)
typedef intptr_t ssize_t;
# define _SSIZE_T_
# define _SSIZE_T_DEFINED
#endif
Compiler complains
magick-baseconfig.h(182): error C2371: 'ssize_t' : redefinition; different basic types
For kicks and giggles, I tried changing long to intptr_t and got
imagemagick.obj : error LNK2001: unresolved external symbol "public: __thiscall
Magick::Geometry::Geometry(unsigned int,unsigned int,int,int,bool,bool)" (??0G eometry@Magick@@QAE@IIHH_N0@Z) [D:\Users\Josh\Documents\js\node-imagemagick-nat ive\build\imagemagick.vcxproj]
D:\Users\Josh\Documents\js\node-imagemagick-native\build\Release\imagemagick.no de : fatal error LNK1120: 1 unresolved externals [D:\Users\Josh\Documents\js\no de-imagemagick-native\build\imagemagick.vcxproj]
Additional information here: https://github.com/mash/node-imagemagic ... e/issues/5

Any ideas how I can get ImageMagick working with node x86?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Can't build a nodejs addon that links to IM x86 Windows

Post by magick »

Add
  • #define _SSIZE_T 1
to magick-baseconfig.h.
josh3736
Posts: 8
Joined: 2013-07-12T12:42:16-07:00
Authentication code: 6789

Re: Can't build a nodejs addon that links to IM x86 Windows

Post by josh3736 »

Adding

Code: Select all

#define _SSIZE_T_ 1
to magick-baseconfig.h gives me:

Code: Select all

  C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\CL.exe /c /I"D:\Us
  ers\Josh\.node-gyp\0.10.13\src" /I"D:\Users\Josh\.node-gyp\0.10.13\deps\uv\in
  clude" /I"D:\Users\Josh\.node-gyp\0.10.13\deps\v8\include" /I"C:\Program File
  s (x86)\ImageMagick-6.8.5-Q16\include" /Zi /nologo /W3 /WX- /Ox /Ob2 /Oi /Ot
  /Oy /GL /D WIN32 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D
  BUILDING_V8_SHARED=1 /D BUILDING_UV_SHARED=1 /D BUILDING_NODE_EXTENSION /D _W
  INDLL /GF /Gm- /MT /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /GR- /Fo"Rele
  ase\obj\imagemagick\\" /Fd"Release\obj\imagemagick\vc100.pdb" /Gd /TP /wd4251
   /analyze- /errorReport:queue ..\src\imagemagick.cc /MP
  imagemagick.cc
c:\program files (x86)\imagemagick-6.8.5-q16\include\magick/magick-baseconfig.h
(163): warning C4005: '_SSIZE_T_' : macro redefinition [D:\Users\Josh\Documents
\js\node-imagemagick-native\build\imagemagick.vcxproj]
          d:\users\josh\.node-gyp\0.10.13\deps\uv\include\uv-private/uv-win.h(2
  8) : see previous definition of '_SSIZE_T_'
c:\program files (x86)\imagemagick-6.8.5-q16\include\magick/magick-baseconfig.h
(183): error C2371: 'ssize_t' : redefinition; different basic types [D:\Users\J
osh\Documents\js\node-imagemagick-native\build\imagemagick.vcxproj]
          d:\users\josh\.node-gyp\0.10.13\deps\uv\include\uv-private/uv-win.h(2
  7) : see declaration of 'ssize_t'
c:\program files (x86)\imagemagick-6.8.5-q16\include\magick/pixel-accessor.h(16
3): warning C4244: 'argument' : conversion from 'double' to 'const MagickCore::
MagickRealType', possible loss of data [D:\Users\Josh\Documents\js\node-imagema
gick-native\build\imagemagick.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xlocale(323): wa
rning C4530: C++ exception handler used, but unwind semantics are not enabled.
Specify /EHsc [D:\Users\Josh\Documents\js\node-imagemagick-native\build\imagema
gick.vcxproj]
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Can't build a nodejs addon that links to IM x86 Windows

Post by magick »

Just warnings, it should work.
josh3736
Posts: 8
Joined: 2013-07-12T12:42:16-07:00
Authentication code: 6789

Re: Can't build a nodejs addon that links to IM x86 Windows

Post by josh3736 »

There is an error in there:
magick-baseconfig.h(183): error C2371: 'ssize_t' : redefinition; different basic types
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Can't build a nodejs addon that links to IM x86 Windows

Post by magick »

Ok, try commenting out the ssize_t definition in magick-baseconfig.h. Does that work?
josh3736
Posts: 8
Joined: 2013-07-12T12:42:16-07:00
Authentication code: 6789

Re: Can't build a nodejs addon that links to IM x86 Windows

Post by josh3736 »

Nope:

Code: Select all

  imagemagick.obj : error LNK2001: unresolved external symbol "public: __thisca ll Magick::Geometry::Geometry(unsigned int,unsigned int,int,int,bool,bool)" (?? 0Geometry@Magick@@QAE@IIHH_N0@Z) [D:\Users\Josh\Documents\js\node-imagemagick-n ative\build\imagemagick.vcxproj]
  D:\Users\Josh\Documents\js\node-imagemagick-native\build\Release\imagemagick. node : fatal error LNK1120: 1 unresolved externals [D:\Users\Josh\Documents\js\ node-imagemagick-native\build\imagemagick.vcxproj]
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Can't build a nodejs addon that links to IM x86 Windows

Post by magick »

Ok, try defining _SSIZE_T_DEFINED to 1 in magick-baseconfig.h. If that does not work, post a bug report to NodeJS. Maybe they have a suggestion.
josh3736
Posts: 8
Joined: 2013-07-12T12:42:16-07:00
Authentication code: 6789

Re: Can't build a nodejs addon that links to IM x86 Windows

Post by josh3736 »

Issue resolved.

Turns out this was an issue with the module's build configuration and the order of includes.

Thanks for your help.
Post Reply