Community
cancel
Showing results for 
Search instead for 
Did you mean: 
PPang2
Novice
1,821 Views

How to call C++ function from Node.js program on a Galileo Gen2.

Hi

I am new to Node.js, but need to call a C++ function from Node.js program and get the return value from the call.

I tried to follow this example http://blog.scottfrees.com/c-processing-from-node-js http://blog.scottfrees.com/c-processing-from-node-js

 

But ran into errors when I installed JS modules( see output log below)

 

/iotProj/cppfromjs/nodecpp-demo# npm install -g node-gyp

 

And the makefile could not run due to compiler option "-Wc++11-extensions"

https://github.com/freezer333/nodecpp-demo/blob/master/cpp/Makefile nodecpp-demo/Makefile at master · freezer333/nodecpp-demo · GitHub

g++ -g -Wall -Wc++11-extensions -std=c++11 -o rainfall rainfall.cc rainfall_test.cc

Wonder if this is the right way to reach my goal, solve the node-gyp module errors and upgrade C++ compiler to version 11 and continue with this example, or

if there is alternative way to call a C++ function from Node.js?

Any advise is appreciated!

Thanks

Jade Dragon

root@galileo:/iotProj/cppfromjs/nodecpp-demo/cpp# node-gyp configure build

gyp info it worked if it ends with ok

gyp info using node-gyp@3.2.1

gyp info using node@0.10.38 | linux | ia32

gyp info spawn /usr/bin/python2

gyp info spawn args [ '/usr/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 '/iotProj/cppfromjs/nodecpp-demo/cpp/build/config.gypi',

gyp info spawn args '-I',

gyp info spawn args '/usr/lib/node_modules/node-gyp/addon.gypi',

gyp info spawn args '-I',

gyp info spawn args '/home/root/.node-gyp/0.10.38/common.gypi',

gyp info spawn args '-Dlibrary=shared_library',

gyp info spawn args '-Dvisibility=default',

gyp info spawn args '-Dnode_root_dir=/home/root/.node-gyp/0.10.38',

gyp info spawn args '-Dnode_gyp_dir=/usr/lib/node_modules/node-gyp',

gyp info spawn args '-Dnode_lib_file=node.lib',

gyp info spawn args '-Dmodule_root_dir=/iotProj/cppfromjs/nodecpp-demo/cpp',

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' ]

make: Entering directory '/iotProj/cppfromjs/nodecpp-demo/cpp/build'

CXX(target) Release/obj.target/rainfall/rainfall.o

CXX(target) Release/obj.target/rainfall/rainfall_node.o

../rainfall_node.cc: In function 'void WorkAsyncComplete(uv_work_t*, int)':

../rainfall_node.cc:53:40: error: no matching function for call to 'v8::HandleScope::HandleScope(v8::Isolate*&)'

<span style="font-size: 13.3333px; font-family: Arial; color: #...

6 Replies
Carlos_M_Intel
Employee
112 Views

Hi Jade,

Which is the function you want to use in NodeJS? Have you tried to create a class in NodeJS in order to run an equivalent command on Javascript?

In which step did you start getting problems:

https://github.com/freezer333/nodecpp-demo https://github.com/freezer333/nodecpp-demo

http://blog.scottfrees.com/c-processing-from-node-js http://blog.scottfrees.com/c-processing-from-node-js

Try running g++ -g -Wall -std=c++11 -o rainfall rainfall.cc rainfall_test.cc this shouldn't give you problems but you may need to install other libraries in your board.

Regards,

Charlie

Carlos_M_Intel
Employee
112 Views

Hi Jade,

Do you have updates on this? I would like to know if you have been able to use this functionality.

Regards,

Charlie

PPang2
Novice
112 Views

my update is that something happen to my old Galileo Gen 2 so I can't run my programs.

I have problems just transfer my microSD card with "full" linux image and development tools to a new Galileo Gen 2 board.

Started up new Galileo board with my good backup image on sd card gave me this error:

 

ASSERT_EFI_ERROR (Status = Aborted)

*****************************************************************

***** ERROR: System boot failure!!!!!!! *****

***** - Press 'R' if you wish to force system recovery *****

***** (connect USB key with recovery module first) *****

***** - Press any other key to attempt another boot *****

*****************************************************************

New boot attempt selected........

 

'R'

 

Recovery boot selected..........

*****************************************************************

***** ERROR: System boot failure!!!!!!! *****

***** - Press 'R' if you wish to force system recovery *****

***** (connect USB key with recovery module first) *****

***** - Press any other key to attempt another boot *****

*****************************************************************

 

Please help me with a link or what to do to get it up and running.

I have search support and forums for cases of "move from one Galileo to another" topics

without luck.

 

Thanks

Jade

 

 

 

 

Carlos_M_Intel
Employee
112 Views

Hi Jade,

I'm sorry to hear that you are having problems with the board. I would like to help you but I will need more information

1. Are you receiving the same error message if you try to boot the board without the SD card?

2. Does the board have the latest firmware? http://downloadmirror.intel.com/24748/eng/IntelGalileoFirmwareUpdaterUserGuide-1.0.4.pdf Galileo Firmware Updater User Guide 1.0.4.

3. Are you able to use the SD card on the other board?

Please let me know about this. If you are having the same error message while booting the board without the SD card, try with the following recovery methods:

http://www.intel.com/content/www/us/en/support/boards-and-kits/intel-galileo-boards/000006449.html How to Fix a Bricked Intel Galileo Board for Boards and Kits - With Dediprog

http://www.intel.com/content/www/us/en/support/boards-and-kits/intel-galileo-boards/000006378.html Recovery Mode for Boards and Kits

Regards,

Charlie

Carlos_M_Intel
Employee
112 Views

Hi Jade,

Have you been able to recover the board? I would like to know which methods have you tried and the outcome.

If you still have problems with the board, open a case by filling this form: http://www.intel.com/support/mailform/maker/edisonwarrantyemail.htm Intel Support and mention this case.

Regards,

Charlie

Carlos_M_Intel
Employee
112 Views

Hi JadeDragon

Have you been able to work on this? Were you able to recover the full functionality of the board?

Regards,

Charlie

Reply