Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compilation fails #47

Closed
ljubomirb opened this issue Dec 16, 2016 · 6 comments
Closed

compilation fails #47

ljubomirb opened this issue Dec 16, 2016 · 6 comments

Comments

@ljubomirb
Copy link

Hi,
Is is possible to prebuild c++ file without node present? That is - to have my working c++ project, and just to include nbind/nbind.h like in examples, and then just compile using g++ or windows studio and have a working exec? I'm trying to do this with visual studio 2015, but

NBIND_GLOBAL() { //explicit type is missing error
	function(sayHello); //identifier NBIND_FUNCTION is undefined error
}

there is also error with callback function...
I'm interested in doing it this way, since I plan to use node in embedded enviroment, and it complicated to cross compile.
Maybe I'm just missing something trivial?

@jjrv
Copy link
Member

jjrv commented Dec 16, 2016

Did I understand correctly that you want to compile an executable which does not use Node.js, and include nbind.h and an NBIND_GLOBAL block but not have them do anything?

In that case just put #ifdef NBIND_GLOBAL around the NBIND_GLOBAL block so the preprocessor will remove it. Then make sure BUILDING_NODE_EXTENSION is not defined in the Makefile or Visual Studio project. Normally node-gyp will add it.

If instead you're trying to cross-compile a Node.js addon without the Node.js headers installed, the addon won't work.

@ljubomirb
Copy link
Author

ljubomirb commented Dec 16, 2016

Sorry for I was not clear. I'm indeed trying to compile c++ executable that is going to be used by node. But, I must compile separately. I do not know what node version will it be.
Also, exec must be able to run even if node is down. That is - exec will be started by system, and node will be or may not be started at all.
The way it is now is - I have exec listening low level perifery, then map key stuff to mqtt, and then - node (if running) is listening mqtt. I was just wandering if this way (with nbind) is with a bit less overhead, and also - it would give me more flexibility. If my idea of using it is correct.
However - I'm not able to compile ANY of your examples (as of today). I do see errors I described, looking like there is no library, but my #include path is there and no problem with it. I can post screenshot if that would help.
EDIT: to be clear - at the moment, I do not worry if node will start cpp exec or system, my only worry is that - I need to be able to compile exec separately, but I'm unable to do it now, so - is it because only npm install can do that, or - i'm missing something in every single example?
nbind

@jjrv
Copy link
Member

jjrv commented Dec 16, 2016

nbind is currently meant for Node.js addons which are actually libraries loaded with dlopen or similar. It's designed to also allow code using nbind to be linked into an executable. In that case, however, it won't do anything. It's important to use #ifdef NBIND_GLOBAL and #ifdef NBIND_CLASS around such blocks, because they will be undefined when compiling a normal executable.

There's simply no standard mechanism for your executable to communicate with Node.

I'm interested in adding a new communication channel that would work by sending binary messages in a standard format between C++ and JavaScript, and would somewhat fit your case. However, it's still in planning and unimplemented. Also, I was still planning the C++ code to run in the same process as Node.js. Your case sounds like it would involve some sort of inter-process communication. That's not entirely out of scope of nbind in the future, but in the near term there's nothing like that implemented.

@jjrv
Copy link
Member

jjrv commented Dec 16, 2016

If you have time and interest, I can help you extend nbind in the necessary ways, with the goal of adding the new code in the official repo. However, expect it to take several weeks of full-time work.

@ljubomirb
Copy link
Author

well, to be honest, I will use some other solution or approach, but I will send you my contact now, to see if I can help you in some way.

@jjrv
Copy link
Member

jjrv commented Dec 18, 2016

Thanks! I'll close this for now, then. A better solution will probably appear some day, but unfortunately not any time soon.

@jjrv jjrv closed this as completed Dec 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants