Giter VIP home page Giter VIP logo

gyp's Introduction

gyp

use

  1. download third party, sh third-party.sh

  2. config your binding.gyp

    if dependent on zlib, you can add the following code to binding.gyp

    "dependencies": [
        "./gyp/zlib.gyp:zlib"
    ]

    Sample:

    {
        "targets": [{
            "target_name": "addon",
            
            ...
    
            "dependencies": [
                "./gyp/zlib.gyp:zlib"
            ]
    
            ...
            
        }]
    }

F&Q

  • for windows

    • require cygwin, need wget
    • giflib, 'not found unistd.h', you can delete #include <unistd.h>
    • libjpeg-turbo, must require CMAKE, can download from http://www.cmake.org/download/
  • for Linux / Mac

    • require wgetcmake

gyp's People

Contributors

oxund avatar wshxbqq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

gyp's Issues

mac上编译代码时报错:error: implicit declaration of function 'put_scanline_someplace' is invalid in C99 [-Werror,-Wimplicit-function-declaration]

gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
CC(target) Release/obj.target/libjpeg-turbo/gyp/third-party/libjpeg-turbo/example.o
../gyp/third-party/libjpeg-turbo/example.c:380:5: error: implicit declaration of function 'put_scanline_someplace' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
put_scanline_someplace(buffer[0], row_stride);
^
1 error generated.
make: *** [Release/obj.target/libjpeg-turbo/gyp/third-party/libjpeg-turbo/example.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Users/lds/.nvm/versions/node/v8.17.0/lib/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at emitTwo (events.js:126:13)
gyp ERR! stack at ChildProcess.emit (events.js:214:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Darwin 21.4.0
gyp ERR! command "/Users/lds/.nvm/versions/node/v8.17.0/bin/node" "/Users/lds/.nvm/versions/node/v8.17.0/bin/node-gyp" "build"
gyp ERR! cwd /Users/lds/Desktop/images-lds
gyp ERR! node -v v8.17.0
gyp ERR! node-gyp -v v9.0.0
gyp ERR! not ok

编译通过,生成的时候提示“unistd.h“找不到,根据说明文件,删除后报错。

D:\desktop\node-images-master>node-gyp configure
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info find Python using Python version 2.7.17 found at "E:\tool\Python27\python.exe"
gyp info find VS using VS2019 (16.3.29418.71) found at:
gyp info find VS "d:\Microsoft Visual Studio\2019\Community"
gyp info find VS run with --verbose for detailed information
gyp info spawn E:\tool\Python27\python.exe
gyp info spawn args [ 'C:\Users\gqz\AppData\Roaming\npm\node_modules\node-gyp\gyp\gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'msvs',
gyp info spawn args '-I',
gyp info spawn args 'D:\desktop\node-images-master\build\config.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\Users\gqz\AppData\Roaming\npm\node_modules\node-gyp\addon.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\Users\gqz\AppData\Local\node-gyp\Cache\10.16.0\include\node\common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=C:\Users\gqz\AppData\Local\node-gyp\Cache\10.16.0',
gyp info spawn args '-Dnode_gyp_dir=C:\Users\gqz\AppData\Roaming\npm\node_modules\node-gyp',
gyp info spawn args '-Dnode_lib_file=C:\\Users\\gqz\\AppData\\Local\\node-gyp\\Cache\\10.16.0\\<(target_arch)\\node.lib',
gyp info spawn args '-Dmodule_root_dir=D:\desktop\node-images-master',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'D:\desktop\node-images-master\build',
gyp info spawn args '-Goutput_dir=.' ]
gyp info ok

编译通过

D:\desktop\node-images-master>node-gyp build
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info spawn d:\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args '/clp:Verbosity=minimal',
gyp info spawn args '/nologo',
gyp info spawn args '/p:Configuration=Release;Platform=x64' ]
在此解决方案中一次生成一个项目。若要启用并行生成,请添加“-m”开关。
libpng.vcxproj -> D:\desktop\node-images-master\build\Release\libpng.lib
libjpeg-turbo.vcxproj -> D:\desktop\node-images-master\build\Release\libjpeg-turbo.lib
dgif_lib.c
gif_err.c
D:\desktop\node-images-master\gyp\third-party\giflib\lib\gif_hash.h(10,10): fatal error C1083: 无法打开包括文件: “unistd.h”: No such file or directory (编译源文件 ......\gyp\third-party\giflib\lib\gif_err.c) [D:\desktop\node-images-master\build\gy
p\gyp\giflib.vcxproj]
D:\desktop\node-images-master\gyp\third-party\giflib\lib\dgif_lib.c(15,10): fatal error C1083: 无法打开包括文件: “unistd.h”: No such file or directory [D:\desktop\node-images-master\build\gyp\gyp\giflib.vcxproj]
zlib.vcxproj -> D:\desktop\node-images-master\build\Release\zlib.lib
gyp ERR! build error
gyp ERR! stack Error: d:\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\gqz\AppData\Roaming\npm\node_modules\node-gyp\lib\build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:198:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "E:\tool\nodejs\node.exe" "C:\Users\gqz\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js" "build"
gyp ERR! cwd D:\desktop\node-images-master
gyp ERR! node -v v10.16.0
gyp ERR! node-gyp -v v6.0.1
gyp ERR! not ok

build 失败 提示“unistd.h”: No such file or directory

删除后 重新编译 生成

D:\desktop\node-images-master>node-gyp build
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info spawn d:\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args '/clp:Verbosity=minimal',
gyp info spawn args '/nologo',
gyp info spawn args '/p:Configuration=Release;Platform=x64' ]
在此解决方案中一次生成一个项目。若要启用并行生成,请添加“-m”开关。
libpng.vcxproj -> D:\desktop\node-images-master\build\Release\libpng.lib
libjpeg-turbo.vcxproj -> D:\desktop\node-images-master\build\Release\libjpeg-turbo.lib
dgif_lib.c
gif_err.c
D:\desktop\node-images-master\gyp\third-party\giflib\lib\dgif_lib.c(383,23): warning C4018: “<”: 有符号/无符号不匹配 [D:\desktop\node-images-master\build\gyp\gyp\giflib.vcxproj]
giflib.vcxproj -> D:\desktop\node-images-master\build\Release\giflib.lib
zlib.vcxproj -> D:\desktop\node-images-master\build\Release\zlib.lib
Image.cc
D:\desktop\node-images-master\src\Image.cc(174,17): warning C4101: “status”: 未引用的局部变量 [D:\desktop\node-images-master\build\binding.vcxproj]
D:\desktop\node-images-master\src\Image.cc(365,21): error C2131: 表达式的计算结果不是常数 [D:\desktop\node-images-master\build\binding.vcxproj]
D:\desktop\node-images-master\src\Image.cc(365,21): message : 因读取超过生命周期的变量而失败 [D:\desktop\node-images-master\build\binding.vcxproj]
D:\desktop\node-images-master\src\Image.cc(365,21): message : 请参见“argc”的用法 [D:\desktop\node-images-master\build\binding.vcxproj]
D:\desktop\node-images-master\src\Image.cc(392,21): error C2131: 表达式的计算结果不是常数 [D:\desktop\node-images-master\build\binding.vcxproj]
D:\desktop\node-images-master\src\Image.cc(392,21): message : 因读取超过生命周期的变量而失败 [D:\desktop\node-images-master\build\binding.vcxproj]
D:\desktop\node-images-master\src\Image.cc(392,21): message : 请参见“argc”的用法 [D:\desktop\node-images-master\build\binding.vcxproj]
D:\desktop\node-images-master\src\Image.cc(437,21): error C2131: 表达式的计算结果不是常数 [D:\desktop\node-images-master\build\binding.vcxproj]
D:\desktop\node-images-master\src\Image.cc(437,21): message : 因读取超过生命周期的变量而失败 [D:\desktop\node-images-master\build\binding.vcxproj]
D:\desktop\node-images-master\src\Image.cc(437,21): message : 请参见“argc”的用法 [D:\desktop\node-images-master\build\binding.vcxproj]
D:\desktop\node-images-master\src\Image.cc(480,21): error C2131: 表达式的计算结果不是常数 [D:\desktop\node-images-master\build\binding.vcxproj]
D:\desktop\node-images-master\src\Image.cc(480,21): message : 因读取超过生命周期的变量而失败 [D:\desktop\node-images-master\build\binding.vcxproj]
D:\desktop\node-images-master\src\Image.cc(480,21): message : 请参见“argc”的用法 [D:\desktop\node-images-master\build\binding.vcxproj]
D:\desktop\node-images-master\src\Image.cc(521,21): error C2131: 表达式的计算结果不是常数 [D:\desktop\node-images-master\build\binding.vcxproj]
D:\desktop\node-images-master\src\Image.cc(521,21): message : 因读取超过生命周期的变量而失败 [D:\desktop\node-images-master\build\binding.vcxproj]
D:\desktop\node-images-master\src\Image.cc(521,21): message : 请参见“argc”的用法 [D:\desktop\node-images-master\build\binding.vcxproj]
D:\desktop\node-images-master\src\Image.cc(591,21): error C2131: 表达式的计算结果不是常数 [D:\desktop\node-images-master\build\binding.vcxproj]
D:\desktop\node-images-master\src\Image.cc(591,21): message : 因读取超过生命周期的变量而失败 [D:\desktop\node-images-master\build\binding.vcxproj]
D:\desktop\node-images-master\src\Image.cc(591,21): message : 请参见“argc”的用法 [D:\desktop\node-images-master\build\binding.vcxproj]
D:\desktop\node-images-master\src\Image.cc(644,21): error C2131: 表达式的计算结果不是常数 [D:\desktop\node-images-master\build\binding.vcxproj]
D:\desktop\node-images-master\src\Image.cc(644,21): message : 因读取超过生命周期的变量而失败 [D:\desktop\node-images-master\build\binding.vcxproj]
D:\desktop\node-images-master\src\Image.cc(644,21): message : 请参见“argc”的用法 [D:\desktop\node-images-master\build\binding.vcxproj]
D:\desktop\node-images-master\src\Image.cc(684,21): error C2131: 表达式的计算结果不是常数 [D:\desktop\node-images-master\build\binding.vcxproj]
D:\desktop\node-images-master\src\Image.cc(684,21): message : 因读取超过生命周期的变量而失败 [D:\desktop\node-images-master\build\binding.vcxproj]
D:\desktop\node-images-master\src\Image.cc(684,21): message : 请参见“argc”的用法 [D:\desktop\node-images-master\build\binding.vcxproj]
D:\desktop\node-images-master\src\Image.cc(855,9): warning C4146: 一元负运算符应用于无符号类型,结果仍为无符号类型 [D:\desktop\node-images-master\build\binding.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: d:\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\gqz\AppData\Roaming\npm\node_modules\node-gyp\lib\build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:198:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "E:\tool\nodejs\node.exe" "C:\Users\gqz\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js" "build"
gyp ERR! cwd D:\desktop\node-images-master
gyp ERR! node -v v10.16.0
gyp ERR! node-gyp -v v6.0.1
gyp ERR! not ok

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.