From 83b41c2fe46a7693aba291ffa740932a9f142be2 Mon Sep 17 00:00:00 2001 From: Nicola Del Gobbo Date: Tue, 2 Apr 2019 20:44:59 +0200 Subject: [PATCH] Document adding -fvisibility=hidden flag for macOS users * -fvisibility=hidden flag for macOS user Added section to remember the macOS user to add the `-fvisibility=hidden` flag. PR-URL: https://github.com/nodejs/node-addon-api/pull/460 Reviewed-By: Gabriel Schulhof Reviewed-By: Michael Dawson --- doc/setup.md | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/doc/setup.md b/doc/setup.md index 36e6fc956..3135bf1d3 100644 --- a/doc/setup.md +++ b/doc/setup.md @@ -55,8 +55,19 @@ To use **N-API** in a native module: ```gyp 'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ], ``` - - 4. Include `napi.h` in the native module code. + 4. If you would like your native addon to support OSX, please also add the + following settings in the `binding.gyp` file: + + ```gyp + ['OS=="mac"', { + 'cflags+': ['-fvisibility=hidden'], + 'xcode_settings': { + 'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden + } + }] + ``` + + 5. Include `napi.h` in the native module code. To ensure only ABI-stable APIs are used, DO NOT include `node.h`, `nan.h`, or `v8.h`.