1

I have the following variable defined in my gyp file (expecting that BASE_DIR is always passed as a command line argument):

'variables': {
  "BOOST_DIR": "<@(BASE_DIR)/../../opt/boost_1_63_0/stage/lib"
},

and I use it as library path for the msbuild linker:

"VCLinkerTool": {
    ...
    "AdditionalLibraryDirectories": [
        "<@(BOOST_DIR)",
        ...
    ]
}

This works perfectly fine as long as I only pass in BASE_DIR via the command line. But when I want to pass a different BOOST_DIR, the linker does not find my library anymore:

node-gyp rebuild --BASE_DIR=... --BOOST_DIR=C:\different\boost\dir\lib

Why does it fail when I pass in the boost directoy via the command line?

David Tanzer
  • 2,732
  • 18
  • 30

1 Answers1

1

OK, found it out myself by looking at the generated .sln in Visual Studio. When I pass in the variable via the command line, the backslashes are missing in the generated solution:

/LIBPATH:"C:differentboostdirlib"

but when I change the path before using it, like in the variable declaration, it seems to work correctly.

So, my workaround is to use

'variables': {
  "BOOST_DIR": "<@(BASE_DIR)/../../opt/boost_1_63_0/stage"
},

and then use the following code to define the library directory:

"VCLinkerTool": {
    ...
    "AdditionalLibraryDirectories": [
        "<@(BOOST_DIR)/lib",
        ...
    ]
}

and that's it: Now the LIBPATH in the .sln is generated correctly:

/LIBPATH:"C:\different\boost\dir\lib"
David Tanzer
  • 2,732
  • 18
  • 30