컴퓨터 공학/JavaScript

N-API 관련 자료 수집

혼새미로 2019. 11. 14. 12:42
반응형

*N-API 공식 홈페이지: https://nodejs.org/api/n-api.html
*N-API 관련 예제: https://github.com/nodejs/node-addon-examples
*node-gyp 설치: https://github.com/nodejs/node-gyp

◆ 팁
*node 모듈을 실행하기 위해서는 해당 컴퓨터의 터미널에서  "yarn global add windows-build-tools"를 입력하여 윈도우 빌드 툴을 설치해야 합니다. (node-gyp 설치 페이지 참고)
*클래스를 생성하기 위해 .cc 파일과 .h 파일을 추가할 경우 binding.gyp에서 targets -> sources에 해당 .cc 파일을 추가해야 합니다. 예를 들어, player 클래스를 추가할 경우 다음과 같이 입력합니다.

{
  "targets": [
    {
      "target_name": "hello",
      "sources": [ "hello.cc" , "player.cc"]
    }
  ]
}

또한, 추가할 헤더 파일에는 반드시 "#include " 를 추가해야 합니다.
https://github.com/nodejs/node/tree/master/test/addons

https://github.com/nodejs/abi-stable-node-addon-examples

반응형