node-addon-api icon indicating copy to clipboard operation
node-addon-api copied to clipboard

fatal error: 'functional' file not found #include <functional>

Open snowdream opened this issue 8 years ago • 10 comments

when i compile, i failed.

node-libsecurity/node_modules/node-addon-api/napi.h:5:10: fatal error: 'functional' file not found #include ^~~~~~~~~~~~ 1 error generated.

version: node-addon-api: 1.2.0 system: macos 10.13.2 node: v9.2.1

snowdream avatar Feb 03 '18 06:02 snowdream

Make sure you have Xcode Command Line tools installed. <functional> is a system header (well, a STL header.)

bnoordhuis avatar Feb 03 '18 09:02 bnoordhuis

@bnoordhuis xcode-select --install xcode-select: error: command line tools are already installed, use "Software Update" to install updates

snowdream avatar Feb 04 '18 02:02 snowdream

@bnoordhuis My node addon is written with c, but not c++.

The functional is in the following dir, but i can not reference it.

"/Library/Developer/CommandLineTools/usr/include/c++/v1/"

if i add the dir into the "include_dirs":of gyp file. errors occur : bogon:lib snowdream$ node-gyp rebuild gyp info it worked if it ends with ok gyp info using [email protected] gyp info using [email protected] | darwin | x64 gyp info spawn /usr/bin/python gyp info spawn args [ '/Users/snowdream/.nvm/versions/node/v9.2.1/lib/node_modules/node-gyp/gyp/gyp_main.py', gyp info spawn args 'binding.gyp', gyp info spawn args '-f', gyp info spawn args 'make', gyp info spawn args '-I', gyp info spawn args '/Users/snowdream/workspace/snowdream/node-libsecurity/lib/build/config.gypi', gyp info spawn args '-I', gyp info spawn args '/Users/snowdream/.nvm/versions/node/v9.2.1/lib/node_modules/node-gyp/addon.gypi', gyp info spawn args '-I', gyp info spawn args '/Users/snowdream/.node-gyp/9.2.1/include/node/common.gypi', gyp info spawn args '-Dlibrary=shared_library', gyp info spawn args '-Dvisibility=default', gyp info spawn args '-Dnode_root_dir=/Users/snowdream/.node-gyp/9.2.1', gyp info spawn args '-Dnode_gyp_dir=/Users/snowdream/.nvm/versions/node/v9.2.1/lib/node_modules/node-gyp', gyp info spawn args '-Dnode_lib_file=/Users/snowdream/.node-gyp/9.2.1/<(target_arch)/node.lib', gyp info spawn args '-Dmodule_root_dir=/Users/snowdream/workspace/snowdream/node-libsecurity/lib', 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 'build', gyp info spawn args '-Goutput_dir=.' ] gyp info spawn make gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ] SOLINK_MODULE(target) Release/nothing.node CC(target) Release/obj.target/security/binding.o In file included from ../binding.c:5: In file included from /Users/snowdream/workspace/snowdream/node-libsecurity/node_modules/node-addon-api/napi.h:5: In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/functional:483: In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/type_traits:387: In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/cstddef:44: /Library/Developer/CommandLineTools/usr/include/c++/v1/__nullptr:55:1: error: unknown type name 'namespace' namespace std ^ /Library/Developer/CommandLineTools/usr/include/c++/v1/__nullptr:55:14: error: expected ';' after top level declarator namespace std ^ In file included from ../binding.c:5: In file included from /Users/snowdream/workspace/snowdream/node-libsecurity/node_modules/node-addon-api/napi.h:5: In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/functional:483: In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/type_traits:387: /Library/Developer/CommandLineTools/usr/include/c++/v1/cstddef:49:7: error: expected ';' after top level declarator using ::size_t; ^ /Library/Developer/CommandLineTools/usr/include/c++/v1/cstddef:49:8: error: expected identifier or '(' using ::size_t; ^ /Library/Developer/CommandLineTools/usr/include/c++/v1/cstddef:53:7: error: expected ';' after top level declarator using ::max_align_t; ^ /Library/Developer/CommandLineTools/usr/include/c++/v1/cstddef:53:8: error: expected identifier or '(' using ::max_align_t; ^ /Library/Developer/CommandLineTools/usr/include/c++/v1/cstddef:58:1: error: unknown type name '_LIBCPP_END_NAMESPACE_STD' _LIBCPP_END_NAMESPACE_STD ^ In file included from ../binding.c:5: In file included from /Users/snowdream/workspace/snowdream/node-libsecurity/node_modules/node-addon-api/napi.h:5: In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/functional:483: /Library/Developer/CommandLineTools/usr/include/c++/v1/type_traits:393:28: error: expected ';' after top level declarator _LIBCPP_BEGIN_NAMESPACE_STD ^ /Library/Developer/CommandLineTools/usr/include/c++/v1/type_traits:396:1: error: unknown type name 'template' template class _LIBCPP_TEMPLATE_VIS reference_wrapper; ^ /Library/Developer/CommandLineTools/usr/include/c++/v1/type_traits:396:10: error: expected identifier or '(' template class _LIBCPP_TEMPLATE_VIS reference_wrapper; ^ /Library/Developer/CommandLineTools/usr/include/c++/v1/type_traits:397:1: error: unknown type name 'template' template struct _LIBCPP_TEMPLATE_VIS hash; ^ /Library/Developer/CommandLineTools/usr/include/c++/v1/type_traits:397:10: error: expected identifier or '(' template struct _LIBCPP_TEMPLATE_VIS hash; ^ /Library/Developer/CommandLineTools/usr/include/c++/v1/type_traits:399:1: error: unknown type name 'template' template ^ /Library/Developer/CommandLineTools/usr/include/c++/v1/type_traits:399:10: error: expected identifier or '(' template ^ /Library/Developer/CommandLineTools/usr/include/c++/v1/type_traits:402:1: error: unknown type name 'template' template ^ /Library/Developer/CommandLineTools/usr/include/c++/v1/type_traits:402:10: error: expected identifier or '(' template ^ /Library/Developer/CommandLineTools/usr/include/c++/v1/type_traits:405:1: error: unknown type name 'template' template <class _Tp, bool> ^ /Library/Developer/CommandLineTools/usr/include/c++/v1/type_traits:405:10: error: expected identifier or '(' template <class _Tp, bool> ^ /Library/Developer/CommandLineTools/usr/include/c++/v1/type_traits:408:1: error: unknown type name 'template' template <bool _Bp, class _If, class _Then> ^ fatal error: too many errors emitted, stopping now [-ferror-limit=] 20 errors generated. make: *** [Release/obj.target/security/binding.o] Error 1 gyp ERR! build error gyp ERR! stack Error: make failed with exit code: 2 gyp ERR! stack at ChildProcess.onExit (/Users/snowdream/.nvm/versions/node/v9.2.1/lib/node_modules/node-gyp/lib/build.js:258:23) gyp ERR! stack at ChildProcess.emit (events.js:159:13) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12) gyp ERR! System Darwin 17.3.0 gyp ERR! command "/Users/snowdream/.nvm/versions/node/v9.2.1/bin/node" "/Users/snowdream/.nvm/versions/node/v9.2.1/bin/node-gyp" "rebuild" gyp ERR! cwd /Users/snowdream/workspace/snowdream/node-libsecurity/lib gyp ERR! node -v v9.2.1 gyp ERR! node-gyp -v v3.6.2 gyp ERR! not ok bogon:lib snowdream$

snowdream avatar Feb 04 '18 03:02 snowdream

What does xcode-select -p print?

As to the build error, napi.h is a C++ header; use node_api.h in C files.

bnoordhuis avatar Feb 04 '18 10:02 bnoordhuis

xcode-select -p /Applications/Xcode.app/Contents/Developer bogon:Developer snowdream$

snowdream avatar Feb 04 '18 16:02 snowdream

So what was the solution, @snowdream ? I'm experiencing /node_modules/weak-napi/node_modules/node-addon-api/napi.h:5:10: fatal error: 'functional' file not found when trying to install npm install node-addon-api.

I verified the installation using xcode-select -p, deleted package-lock.json, cleaned the npm cache, verified that Node is v18, etc., I visited lots of threads and sites where references the fatal error: 'functional' file not found and can't find the solution. I know this issue is pretty old but wondering if I can get some insights from here.

johan-apo avatar Sep 30 '24 21:09 johan-apo

So what was the solution, @snowdream ? I'm experiencing /node_modules/weak-napi/node_modules/node-addon-api/napi.h:5:10: fatal error: 'functional' file not found when trying to install npm install node-addon-api.

I verified the installation using xcode-select -p, deleted package-lock.json, cleaned the npm cache, verified that Node is v18, etc., I visited lots of threads and sites where references the fatal error: 'functional' file not found and can't find the solution. I know this issue is pretty old but wondering if I can get some insights from here.

After spending a day trying to fix the same issue I finally managed to do it by reinstalling xcode-select (though the version didn't change).

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

sqrter avatar Oct 15 '24 10:10 sqrter

So what was the solution, @snowdream ? I'm experiencing /node_modules/weak-napi/node_modules/node-addon-api/napi.h:5:10: fatal error: 'functional' file not found when trying to install npm install node-addon-api. I verified the installation using xcode-select -p, deleted package-lock.json, cleaned the npm cache, verified that Node is v18, etc., I visited lots of threads and sites where references the fatal error: 'functional' file not found and can't find the solution. I know this issue is pretty old but wondering if I can get some insights from here.

After spending a day trying to fix the same issue I finally managed to do it by reinstalling xcode-select (though the version didn't change).

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

same

kurorinto avatar Oct 28 '24 07:10 kurorinto

So what was the solution, @snowdream ? I'm experiencing /node_modules/weak-napi/node_modules/node-addon-api/napi.h:5:10: fatal error: 'functional' file not found when trying to install npm install node-addon-api. I verified the installation using xcode-select -p, deleted package-lock.json, cleaned the npm cache, verified that Node is v18, etc., I visited lots of threads and sites where references the fatal error: 'functional' file not found and can't find the solution. I know this issue is pretty old but wondering if I can get some insights from here.

After spending a day trying to fix the same issue I finally managed to do it by reinstalling xcode-select (though the version didn't change).

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

same here

kenylieou avatar Nov 01 '24 13:11 kenylieou

this is the way

dannyshmueli avatar Mar 19 '25 11:03 dannyshmueli