Automattic / node-canvas

Node canvas is a Cairo backed Canvas implementation for NodeJS.
10.14k stars 1.17k forks source link

Linking error to freetype on Mac OS X High Sierra #1013

Open jonasseglare opened 7 years ago

jonasseglare commented 7 years ago

Issue or Feature

After upgrading to Mac OS X High Sierra, I experienced difficulties in getting our web server that uses canvas to work. Specifically, when launching the server it crashes with the error:

canvas.node, 1): Symbol not found: _FT_Done_Face

The canvas version is 1.6.7

Quick-fix

We managed to fix the problem by adding the line '-lfreetype' to bindings.gyp, so that the relevant portion of that file looks like this:

, 4611, 4714, 4512]
                }
              }
            }
          }
        }, { # 'OS!="win"'
          'libraries': [
            '<!@(pkg-config pixman-1 --libs)',
            '<!@(pkg-config cairo --libs)',
            '<!@(pkg-config libpng --libs)',
            '-lfreetype'
          ],
          'include_dirs': [
            '<!@(pkg-config cairo --cflags-only-I | sed s/-I//g)',
            '<!@(pkg-config libpng --cflags-only-I | sed s/-I//g)'
          ]
        }],
        ['with_freetype=="true"', {
          'defines': [
            'HAVE_FREETYPE'
          ],

Steps to Reproduce

To fix it, edit the file as explained above (adding -lfreetype), call node-gyp rebuild from the node_modules/canvas subdirectory. Launch the web server and it should not crash.

So in short, you need to make sure that we link to freetype.

Your Environment

chearon commented 7 years ago

You're right, although for 1.6.x it should go in the HAVE_FREETYPE section of binding.gyp (and via pkg-config). 2.x is unaffected.

jonasseglare commented 7 years ago

Thanks for the information. I tried to use 2.0.0-alpha.5 and it works directly without any linking errors.