Symbol not found: _libintl_gettext

I am trying to create a NodeJS module using C++ and node-gyp. The package depends on GNU's Gettext library. I am currently using Mac OS X Mountain Lion. I have tried installing the package myself via manual efforts, via Homebrew, and even via Fink.

The program works via Terminal.app and the package compiles. I can use the .node module just fine, except until I use a method in the library that uses gettext. I get the following errors in REPL and then REPL exits.

dyld: lazy symbol binding failed: Symbol not found: _libintl_gettext
  Referenced from: /Users/KevinMartin/Dropbox/www/node-locale/build/Release/locale.node
  Expected in: dynamic lookup

dyld: Symbol not found: _libintl_gettext
  Referenced from: /Users/KevinMartin/Dropbox/www/node-locale/build/Release/locale.node
  Expected in: dynamic lookup

Trace/BPT trap: 5

Thanks in advance.

This is probably happening because you are not listing libintl as a library to be dynamically linked. You need to add something like:

{
  "targets": [
    {
      "target_name": "...",
      "sources": ["..."],
      "libraries": ["/path/to/gettext/lib/libintl.a"]
    }
}

to your binding.gyp file. libintl isn't being linked in your app, statically or dynamically, that is why you get the symbol error.

Edit:

You can probably also do something like:

{
    "targets": [{
        "target_name": "...",
        "sources": [
            "..."
        ],
        "link_settings": {
             "libraries": ["libintl.8.dylib"]
        }
     }]
}