gyp – 如何指定链接库的风格
我正在编写一个本地节点模块,我希望能够在发行版和debugging版本中构build它。
节点模块链接到另一个库,该库在两个不同的目录中具有debugging版本和发行版本。
现在,这是我被卡住的地方 – 我如何指定目前正在构build的configuration库目录?
我已经尝试在configurations.debug.link_settings键中设置,但是我得到错误:'在debuggingconfiguration中不允许link_settings,在目标binding.gyp中find
显然这是不可能的跨平台的方式。 所以希望这会让你花上几个小时的实验。
这是一个为Mac和Windows构build插件的gyp文件。
//This example assumes you have an external library 'thelibrary', located in //./external/thelibrary //With the two flavors, debug and release in lib/debug and lib/release { "targets": [ { "target_name": "addon", "sources": [ "src/addon.cpp", "src/expose_the_library.cpp" ], "include_dirs": [ "external/thelibrary/include" ], "cflags!": [ "-fno-exceptions" ], "cflags_cc!": [ "-fno-exceptions" ], "conditions": [ [ "OS=='mac'", { "defines": [ "__MACOSX_CORE__" ], "architecture": "i386", "xcode_settings": { "GCC_ENABLE_CPP_EXCEPTIONS": "YES" }, "link_settings": { "libraries": [ "-lthelibrary", "-framework", "IOBluetooth" //this is how you use a framework on OSX ], "configurations": { "Debug": { "xcode_settings": { "OTHER_LDFLAGS": [ "-Lexternal/thelibrary/lib/debug" ] } }, "Release": { "xcode_settings": { "OTHER_LDFLAGS": [ "-Lexternal/thelibrary/lib/release" ] } } } } } ], [ "OS=='win'", { "link_settings": { "libraries": [ "-lthelibrary.lib", ] }, "configurations": { "Debug": { "msvs_settings": { "VCCLCompilerTool": { "ExceptionHandling": "0", "AdditionalOptions": [ "/MP /EHsc" ] }, "VCLibrarianTool": { "AdditionalOptions": [ "/LTCG" ] }, "VCLinkerTool": { "LinkTimeCodeGeneration": 1, "LinkIncremental": 1, "AdditionalLibraryDirectories": [ "../external/thelibrary/lib/debug" ] } } }, "Release": { "msvs_settings": { "VCCLCompilerTool": { "RuntimeLibrary": 0, "Optimization": 3, "FavorSizeOrSpeed": 1, "InlineFunctionExpansion": 2, "WholeProgramOptimization": "true", "OmitFramePointers": "true", "EnableFunctionLevelLinking": "true", "EnableIntrinsicFunctions": "true", "RuntimeTypeInfo": "false", "ExceptionHandling": "0", "AdditionalOptions": [ "/MP /EHsc" ] }, "VCLibrarianTool": { "AdditionalOptions": [ "/LTCG" ] }, "VCLinkerTool": { "LinkTimeCodeGeneration": 1, "OptimizeReferences": 2, "EnableCOMDATFolding": 2, "LinkIncremental": 1, "AdditionalLibraryDirectories": [ "../external/thelibrary/lib/release" ] } } } } } ] ] } ] }
- 安装contextify-node-gyp重build失败时出错
- 在npm安装期间,在mac 10.5.8上findnode-gyp'pkg-config:command not found'
- 错误:'REPLACE_INVALID_UTF8'不是'v8 :: String'的成员
- 在通过命令行传递时,node-gypvariables的行为有所不同
- 电子本机添加:DLL初始化例程失败
- Fibers / Node-Gyp悬挂在纱线上
- 无法在NodeJS中使用本机Windows库
- gyp ERR! 在安装angular 4项目时在ubuntu中configuration错误
- 在OpenShift上找不到模块'../build/Debug/iconv.node'