Node-gyp Include and Library Directories with Boost

16,286

You need to add them in the binding.gyp file:

'include_dirs': [
  '<some directory>',
],
'libraries': [
  '-l<some library>', '-L<some library directory>'
]
Share:
16,286
Aetylus
Author by

Aetylus

Updated on July 18, 2022

Comments

  • Aetylus
    Aetylus almost 2 years

    I'm attempting to build a Node C++ addon on my Windows 7 machine that uses some classes from the Boost libraries. However, after running

    node-gyp configure
    

    successfully, I'm continually assaulted by missing header files when I run

    node-gyp build
    

    relating to various Boost headers I included.

    I tried setting up the include and library directories manually in the Visual Studio projects created by "configure," but to no avail.

    How exactly does one go about defining include directories for node-gyp?

    [Edit] After messing around with node-gyp with little success, I explored into building Node modules through Visual Studio instead and, turns out, after several hours, it's finally up and working. Thanks for the assistance.

  • Jonathan Wiepert
    Jonathan Wiepert about 11 years
  • Aetylus
    Aetylus about 11 years
    Right now, my binding.gyp file looks like this. However, I'm still receiving an error about being unable to find the included header files. Am I doing something wrong?
  • Jonathan Wiepert
    Jonathan Wiepert about 11 years
    Can you paste the directory listing of C:\Boost\boost_1_53_0?
  • Jonathan Wiepert
    Jonathan Wiepert about 11 years
    From boost.org: To compile anything in Boost, you need a directory containing the boost\ subdirectory in your #include path. Specific steps for setting up #include paths in Microsoft Visual Studio follow later in this document; if you use another IDE, please consult your product's documentation for instructions. So I think you need: "include_dirs": [ "C:\Boost\boost_1_53_0\boost" ]
  • Aetylus
    Aetylus about 11 years
    C:\Boost\boost_1_53_0 * bin * bin.v2 * boost * doc * libs * more * stage * status * tools Would it have to point to the "boost" folder? When I'm working with Boost regularly in VS, I set the include directory just to boost_1_53_0 and that works just fine.
  • Aetylus
    Aetylus about 11 years
    Tried it and still running into the same issue.
  • Aetylus
    Aetylus about 11 years
    "c:[Project Directory]\Point.h(17): fatal error C1083: Cannot open include file: 'boost/shared_ptr.hpp': No such file or directory (..\Project.cpp) [C:[Project Directory]\build\project.vcxproj]"
  • Jonathan Wiepert
    Jonathan Wiepert about 11 years
    Your include line in the source should be #include <shared_ptr.hpp>, is this what you have?
  • Jonathan Wiepert
    Jonathan Wiepert about 11 years
    Also, are you sure you want to use direct_dependent_settings? If you are including those header files from the sources in the target, you want the include_dirs directive to be at the same level as sources in your config.
  • Aetylus
    Aetylus about 11 years
    I'm getting the same error now, except with "... open include file: 'shared_ptr.hpp' ... ". Also, I'm not sure about the direct_dependent_settings, but that's how it was set up in one example in the gyp wiki. I had previously tried it without, which ended up in the same error as it currently is now.
  • Jonathan Wiepert
    Jonathan Wiepert about 11 years
    If your not sure, use both until you can figure out what you need. i.e. an include_dirs directive inside and outside of direct_dependent_settings. Also, from looking at Windows examples, it looks like you need to escape the path: "include_dirs": [ "C:\\Boost\\boost_1_53_0\\boost" ]
  • Aetylus
    Aetylus about 11 years
    Sorry for the late response. The escape path did help with finding the path, however I'm not running into another error. "LINK : fatal error LNK1181: cannot open input file '[boost directory]\stage\lib.lib' [project directory]"
  • Jonathan Wiepert
    Jonathan Wiepert about 11 years
    Did you escape the path there as well? Can you post your updated binding.gyp?
  • Aetylus
    Aetylus about 11 years
    After messing around with node-gyp with little success, I explored into building Node modules through Visual Studio instead and, turns out, after several hours, it's finally up and working. Thanks for the assistance.