How to embed NodeJS into my application?

3,450 views
Skip to first unread message

philip andrew

unread,
Jul 16, 2013, 1:03:42 AM7/16/13
to nod...@googlegroups.com
Hi,

I have a C++ application and I want to embed NodeJS into it on XCode and Visual C++, how can I do this?

Thanks, Philip

Ryan Schmidt

unread,
Jul 17, 2013, 2:58:18 AM7/17/13
to nod...@googlegroups.com

On Jul 16, 2013, at 00:03, philip andrew wrote:

> I have a C++ application and I want to embed NodeJS into it on XCode and Visual C++, how can I do this?

How to use node as a library was recently asked on this list, and the response was that node is not designed to be used as a library so it may not be straightforward or even possible to do this at this time. Check the archives.

Stephen Belanger

unread,
Jul 17, 2013, 3:02:36 AM7/17/13
to nod...@googlegroups.com

Yep, not possible currently.

I've asked about it before, and considered building it myself. But it was decided that it wasn't useful to enough people to add the extra complexity. I've seen a lot of people ask about it lately though. It might be time to reevaluate that.

--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


philip andrew

unread,
Jul 17, 2013, 9:40:53 AM7/17/13
to nod...@googlegroups.com
Hi Stephen,

I made some attempt to use it in my OSX XCode development environment but failed, firstly I tried to compile NodeJS in XCode but noticed that there's no project for it. So then obtained V8 and compiled that in XCode then attempted to add NodeJS to the V8 project, but failed in doing that.

I thought, if I can get NodeJS to compile in XCode then at least I can start from there to use NodeJS.

In the better case, NodeJS can be used as a library with a function to start it and stop it.

Phil

mscdex

unread,
Jul 17, 2013, 9:56:16 AM7/17/13
to nod...@googlegroups.com
On Tuesday, July 16, 2013 1:03:42 AM UTC-4, philip andrew wrote:
I have a C++ application and I want to embed NodeJS into it on XCode and Visual C++, how can I do this?

Do you really need node itself or is libuv what you really want?

philip andrew

unread,
Jul 17, 2013, 11:10:12 AM7/17/13
to nod...@googlegroups.com
I want NodeJS server embedded in my C++ application.

Ben Noordhuis

unread,
Jul 17, 2013, 5:05:10 PM7/17/13
to nod...@googlegroups.com
On Wed, Jul 17, 2013 at 5:10 PM, philip andrew <phili...@gmail.com> wrote:
> I want NodeJS server embedded in my C++ application.

You can send and receive file descriptors to and from a node.js
process. That will be much less hassle than trying to embed it.

Stephen Belanger

unread,
Jul 17, 2013, 5:11:54 PM7/17/13
to nod...@googlegroups.com
Depends what you want to do with it. If, for example, you want to use it for scripting a game engine it NEEDS to be in the same process so you can package and distribute it together.

Ryan Schmidt

unread,
Jul 17, 2013, 5:43:00 PM7/17/13
to nod...@googlegroups.com
I would not recommend trying to use nodejs in a game (or other publicly distributed application for that matter) since, from what I understand from previous discussion on this group, the way that v8 dynamically compiles and executes JavaScript code is not permitted under the policies of the Apple app stores so your application could never be distributed there for iOS or OS X.

Stephen Belanger

unread,
Jul 17, 2013, 5:47:25 PM7/17/13
to nod...@googlegroups.com
A good chunk of the game industry doesn't care about Apple. Also, you CAN use dynamic compilation on iOS. It's been allowed since iOS5. No idea about OSX.

Ryan Schmidt

unread,
Jul 17, 2013, 6:35:26 PM7/17/13
to nod...@googlegroups.com

On Jul 17, 2013, at 16:47, Stephen Belanger wrote:

> A good chunk of the game industry doesn't care about Apple.

Developers are free to care or not care about any platform they choose. I just want to make sure developers are aware of any problems they might face trying to port their apps to Apple platforms, should they wish to do so.

A year ago I was interested in maybe using nodejs to develop a game that I wanted to publish for iOS and OS X, and I investigated NodObjC, whose homepage at the time promised (and still does) to let you write iOS and OS X GUI apps in JavaScript, without mentioning that any such apps could not be published to the app stores; without that ability, it's useless, and I didn't want any developers to waste their time investigating this possibility as I did.


> Also, you CAN use dynamic compilation on iOS. It's been allowed since iOS5. No idea about OSX.

Citation?

The previous discussion on this list was 13 months ago, at which time iOS 5 was current:

https://groups.google.com/d/msg/nodejs/7c_0hkdoEGY/NU9dikAuBhwJ

The statement from Jorge was: "iOS wont't let user code jump into a block of writable (from your app's point of view) memory -for security reasons- and it seems that v8's JIT compiler requires that: http://code.google.com/p/v8/issues/detail?id=1312"

There has been some action on that v8 issue lately, but still no evidence of any v8-using app actually getting approved on the app stores.

philip andrew

unread,
Jul 18, 2013, 12:41:34 AM7/18/13
to nod...@googlegroups.com
Hi Ben,

Well I do have NodeJS starting as a process, and I will settle with this until someone can tell me how to embed it. But I don't like it like this - I want it embedded so I can start it and stop it quickly and I can have more control and understanding of what's going on in terms of memory, threads, and so on, it makes more sense of

The reason why? I'm not programing a game, I'm programming a desktop application. The reasons not particularly important from your point of view expect to say that its a requirement to have NodeJS packaged with my application. 

Phil

mscdex

unread,
Jul 18, 2013, 9:27:33 AM7/18/13
to nod...@googlegroups.com
On Thursday, July 18, 2013 12:41:34 AM UTC-4, philip andrew wrote:
The reason why? I'm not programing a game, I'm programming a desktop application. The reasons not particularly important from your point of view expect to say that its a requirement to have NodeJS packaged with my application. 

Would node-webkit work for you?: https://github.com/rogerwang/node-webkit

philip andrew

unread,
Jul 20, 2013, 12:30:16 PM7/20/13
to nod...@googlegroups.com
Yes maybe, thanks, I need to understand it ..... reading

ZECTBynmo

unread,
Jan 2, 2014, 7:10:55 PM1/2/14
to nod...@googlegroups.com
I've been working on a library that allows you to link node.js into your application as a static library:


I'd love some feedback and help working on it!

Floby

unread,
Jan 3, 2014, 3:27:34 AM1/3/14
to nod...@googlegroups.com
Also, maybe you'd be better off embedding your application into node.js rather than embedding node.js into your application.
Reply all
Reply to author
Forward
0 new messages