ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ API Support » how to locate 'imqi.hpp' from node-gyp

Post new topic  Reply to topic Goto page 1, 2  Next
 how to locate 'imqi.hpp' from node-gyp « View previous topic :: View next topic » 
Author Message
sebastia
PostPosted: Wed Jun 17, 2015 8:45 am    Post subject: how to locate 'imqi.hpp' from node-gyp Reply with quote

Grand Master

Joined: 07 Oct 2004
Posts: 1003

Hi.
I am trying to use "nan" module to call MQ_CONNECT() from node.js

See

>>> http://stackoverflow.com/questions/30862736/node-js-and-c-c-integration-how-to-properly-implement-callbacks
and
>>> https://github.com/nodejs/nan

When I use "node-gyp" it says it can not find "imqi.hpp"

As far as I can see, the path to MQ includes has to be provided in "binding.gyp", and I have tried this without success:

Code:
{
        "targets": [
                {
                        "target_name": "mqconn",
                        "sources": [
                                "initall.cc",
                                "mqconn.cc"
                        ],
                        "include_dirs": [
                                "<!(node -e \"require('nan')\")",
                                "c:\MQ\tools\cplus\include"
                        ]
                }
        ]
}


Does anyboby have a clue on this ?
Sebastian.


Last edited by sebastia on Thu Jun 18, 2015 11:31 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
mqjeff
PostPosted: Wed Jun 17, 2015 9:49 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

You may need to point to the libs as well, but I don't see anything obvious in the NAN docs on that.

Are you running node.js in a shell that has setmqenv applied?

Are you writing your own wrapper functions around the mq calls to match the necessary signatures for the NAN integration?
Back to top
View user's profile Send private message
sebastia
PostPosted: Wed Jun 17, 2015 10:04 am    Post subject: Reply with quote

Grand Master

Joined: 07 Oct 2004
Posts: 1003

LIBS : they go into binding.gyp too (AFAIK)
Code:
'include_dirs': [
  '<some directory>',
],
'libraries': [
  '-l<some library>', '-L<some library directory>'
]


SETMQENV - no, but I'd say my PATH is quite complete

Yes, that is what I am trying to achieve, and let me tell you the nan documentation has no simple sample available ... jejeje
Back to top
View user's profile Send private message Visit poster's website
mqjeff
PostPosted: Wed Jun 17, 2015 10:41 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

try putting a trailing slash after the include - "c:\MQ\tools\cplus\include\"

Try converting the \ to / - "c:/MQ/tools/cplus/include"

try it under setmqenv...
Back to top
View user's profile Send private message
sebastia
PostPosted: Thu Jun 18, 2015 9:53 am    Post subject: Reply with quote

Grand Master

Joined: 07 Oct 2004
Posts: 1003

jajaja, Jeff - you were on the right path, but ... jejeje

I asked also in "stackoverflow.com" (node.js fora)

>>> http://stackoverflow.com/questions/30897604/how-to-locate-imqi-hpp-from-node-gyp

... and my IBM/BCN coleague Luis Crespo (also in BP) fixed it - he is a GREAT expert in JavaScript :

Quote:
Because binding.gyp is in JSON, the String "c:\MQ\tools\cplus\include" is a standard JavaScript String, and therefore the \ needs to be escaped to \\.

So you should replace "c:\MQ\tools\cplus\include" into "c:\\MQ\\tools\\cplus\\include".


Lets go for the next step !

Thanks a lot, Jeff.
Should you come to Barcelona, dont hesitate to call me and we shall have a beer downtown !

Sebastian.
Back to top
View user's profile Send private message Visit poster's website
mqjeff
PostPosted: Thu Jun 18, 2015 10:12 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

sebastia wrote:
Should you come to Barcelona, dont hesitate to call me and we shall have a beer downtown !


This is on my list of places to get to... I will let you know!
Back to top
View user's profile Send private message
sebastia
PostPosted: Thu Jun 18, 2015 11:23 am    Post subject: Reply with quote

Grand Master

Joined: 07 Oct 2004
Posts: 1003

Well, I've finished the "compile" part and now have trouble with the "link" phase.

Code:
mqconn.obj : error LNK2001: unresolved external symbol "public: unsigned char __cdecl ImqObj::setName(char const *)" (?
setName@ImqObj@@QEAAEPEBD@Z) [c:\Sebas\JavaScript\MQ_module\build\mqconn.vcxproj]
mqconn.obj : error LNK2001: unresolved external symbol "public: virtual __cdecl ImqErr::~ImqErr(void)" (??1ImqErr@@UEAA
@XZ) [c:\Sebas\JavaScript\MQ_module\build\mqconn.vcxproj]
mqconn.obj : error LNK2001: unresolved external symbol "public: unsigned char __cdecl ImqMgr::connect(void)" (?connect@
ImqMgr@@QEAAEXZ) [c:\Sebas\JavaScript\MQ_module\build\mqconn.vcxproj]
mqconn.obj : error LNK2001: unresolved external symbol "public: virtual __cdecl ImqMgr::~ImqMgr(void)" (??1ImqMgr@@UEAA
@XZ) [c:\Sebas\JavaScript\MQ_module\build\mqconn.vcxproj]
mqconn.obj : error LNK2001: unresolved external symbol "public: __cdecl ImqMgr::ImqMgr(void)" (??0ImqMgr@@QEAA@XZ) [c:\
Sebas\JavaScript\MQ_module\build\mqconn.vcxproj]
c:\Sebas\JavaScript\MQ_module\build\Release\mqconn.node : fatal error LNK1120: 5 unresolved externals [c:\Sebas\JavaScr
ipt\MQ_module\build\mqconn.vcxproj]


Guess it's time to include the LIBs into the "binding.gyp" file.

But I am not very used to C++, that's the truth.

With plain "C", I included "cmqc.h" header and "mqm.lib" lib.

But now with C++, the header is "imqi.hpp" and the truth is I dont remember the name of the LIB file(s).

Got nice URL

>>>> http://www-01.ibm.com/support/knowledgecenter/SSFKSJ_7.5.0/com.ibm.mq.dev.doc/q030490_.htm

... and here is the resulting (and working) "binding.gyp" - just to have the complete answer if someone goes MQ and nan (jejeje)

Code:
{
   "targets": [
      {
         "target_name": "mqconn",
         "sources": [
            "initall.cc",
            "mqconn.cc"
         ],
         "include_dirs": [
            "<!(node -e \"require('nan')\")",
            "c:\\MQ\\tools\\cplus\\include",
            "c:\\MQ\\tools\\c\\include"
         ],
         "libraries": [
            "c:\\MQ\\tools\\Lib64\\imqb23vn.lib",
            "c:\\MQ\\tools\\Lib64\\imqs23vn.lib"
         ]
      }
   ]
}


Back to top
View user's profile Send private message Visit poster's website
mqjeff
PostPosted: Thu Jun 18, 2015 11:39 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Back to top
View user's profile Send private message
sebastia
PostPosted: Thu Jun 18, 2015 11:45 am    Post subject: Reply with quote

Grand Master

Joined: 07 Oct 2004
Posts: 1003

Yes, my C++ code is called (without paramaters yet) and returns twice, without RC yet, even it has learned to print

Code:
ImqQueueManager::connect ended with RC (2059).


I think there is a lot to do before starting the queue manager.
I work very incremental - now want to pass the qmgr name as parameter.
Then, get the RC back.
And only then I shall start qmgr ...

Back to top
View user's profile Send private message Visit poster's website
sebastia
PostPosted: Thu Jun 18, 2015 11:11 pm    Post subject: Reply with quote

Grand Master

Joined: 07 Oct 2004
Posts: 1003

Jeff - I know this is a C++ "class" question, but it is very related to previous items.

I have this code working OK :

Code:
class PiWorker : public contact admin {
public:                                                    ... line 1
PiWorker(NanCallback *callback, int points)                ... line 2
: contact admin(callback), points(points), estimate(0) {}  ... line 3
~PiWorker() {}
( . . . )
} ; // PiWorker : contact admin


Now I need to change the parameter "int points" into "char * szQMN" or similar.

This is, we need to pass the queue manager name from C++ method into the NanoWorker class.

Maybe you can provide some light ...
Back to top
View user's profile Send private message Visit poster's website
mqjeff
PostPosted: Fri Jun 19, 2015 4:21 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

... if it's a private interface - i.e. you wrote it, then it should be as easy as changing the method call.

If it's an API defined for the Nano worker, then you can't change it.

You can either look at putting a structure in some kind of thread-specific/thread safe storage and including the string there, or putting the string into a user space in the structures that Nano provides (if there is a user space).

Roger has more experience working with c-level threading than I do, so he may have some more targeted advice.
Back to top
View user's profile Send private message
sebastia
PostPosted: Fri Jun 19, 2015 4:27 am    Post subject: Reply with quote

Grand Master

Joined: 07 Oct 2004
Posts: 1003

No, it's a private interface, so I can change it, but, a change from an "INTEGER" into a "STRING" is not as easy as it seems !

Right now, the code is

Code:
class PiWorker : public Nan-Async-Worker {
public:
    PiWorker( NanCallback *callback, NanUtf8String sz_QMN )
    : Nan-Async-Worker( callback ) {}     
    ~PiWorker() {}


... I am calling it with these parameters

Code:
NanUtf8String szQMN( args[0]->ToString() ) ;
Nan-Async-Queue-Worker( new PiWorker( callback, szQMN ) ) ;


... and the compiler error is as crazy as

Code:
..\mqconn.cc(126): error C2664:
'PiWorker::PiWorker(const PiWorker &)' :
cannot convert argument 2
from 'NanUtf8String(__cdecl *)(void)'
to 'NanUtf8String'


... pointing to the "calling" line

Have a nice weekend !
Sebastian.


Last edited by sebastia on Fri Jun 19, 2015 4:36 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
mqjeff
PostPosted: Fri Jun 19, 2015 4:32 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

You might try using sprintf or something to create a char/c++ string value, and then pass that to the NanUtf8String constructor. Or creating an empty NanUtf8String and then assigning the value.
Back to top
View user's profile Send private message
sebastia
PostPosted: Fri Jun 19, 2015 4:32 am    Post subject: Reply with quote

Grand Master

Joined: 07 Oct 2004
Posts: 1003

curious

I am trying to write

"class PiWorker : public Nan Async Worker {"

(without the blank spaces)

and it gets changed into "contact admin"

any clue ?


Last edited by sebastia on Fri Jun 19, 2015 4:33 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
mqjeff
PostPosted: Fri Jun 19, 2015 4:33 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

"contact admin" is short for "the forum didn't like your word". No real fix...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » IBM MQ API Support » how to locate 'imqi.hpp' from node-gyp
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.