# calling q in C++ - sample program - steps

**URL:** <https://forum.kx.com/t/calling-q-in-c-sample-program-steps/7059>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [March 13, 2011, 9:31am UTC](https://forum.kx.com/t/calling-q-in-c-sample-program-steps/7059 "2011-03-13T09:31:00Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![RB1](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@RB1](https://forum.kx.com/u/RB1)\
**Post date:** [March 13, 2011, 9:31am UTC](https://forum.kx.com/t/calling-q-in-c-sample-program-steps/7059/1 "2011-03-13T09:31:00Z")

</div>

Could somebody help me in getting some steps in calling q from C++. Iam a learner and some direction is very much appreciated. I got qevaluation copied onto unbuntu. I want to link that with C++ fromeclipse. Thanks for your time and help.

---

<div class="post-metadata">

**Author:** ![f11](https://avatars.discourse-cdn.com/v4/letter/f/2bfe46/32.png) [@f11](https://forum.kx.com/u/f11)\
**Post date:** [March 14, 2011, 12:41am UTC](https://forum.kx.com/t/calling-q-in-c-sample-program-steps/7059/2 "2011-03-14T00:41:00Z")

</div>

Hello,

This is a good place to start:

https://code.kx.com/trac/wiki/Cookbook/InterfacingWithC?(user/pass: anonymous/anonymous.

Regards,

Fintan.

---

<div class="post-metadata">

**Author:** ![RB1](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@RB1](https://forum.kx.com/u/RB1)\
**Post date:** [March 16, 2011, 8:19pm UTC](https://forum.kx.com/t/calling-q-in-c-sample-program-steps/7059/3 "2011-03-16T20:19:00Z")

</div>

Thank you Fintan. I started to write a program, it seems it needs tolink with c.o file, how can I download that object file, there is nooption to download this file from any location. Is there a way?.Thanks for letting me know.On Mar 14, 5:41?am, Fintan Quill \<fint…\> wrote:\> Hello,\>\> This is a good place to start:\>\> [https://code.kx.com/trac/wiki/Cookbook/InterfacingWithC](https://code.kx.com/trac/wiki/Cookbook/InterfacingWithC)(user/pass:\> anonymous/anonymous.\>\> Regards,\>\> Fintan.\>\> On Sun, Mar 13, 2011 at 5:31 AM, RB \<ram\_bo…\> wrote:\> \> Could somebody help me in getting some steps in calling q from C++. I\> \> am a learner and some direction is very much appreciated. I got q\> \> evaluation copied onto unbuntu. I want to link that with C++ from\> \> eclipse. Thanks for your time and help.\>\> \> –\> \>

Submitted via Google Groups\</ram\_bo…\>\</fint…\>

---

<div class="post-metadata">

**Author:** ![Kamil\_Jaskiewic](https://avatars.discourse-cdn.com/v4/letter/k/43a26b/32.png) [@Kamil\_Jaskiewic](https://forum.kx.com/u/Kamil_Jaskiewic)\
**Post date:** [March 16, 2011, 8:22pm UTC](https://forum.kx.com/t/calling-q-in-c-sample-program-steps/7059/4 "2011-03-16T20:22:00Z")

</div>

On 16 March 2011 21:19, RB \<ram\_bollu\> wrote:\> Thank you Fintan. I started to write a program, it seems it needs to\> link with c.o file, how can I download that object file, there is no\> option to download this file from any location. Is there a way?.\> Thanks for letting me know.\>Here is for linux 32-bit:[http://kx.com/q/l32/Regards,Kamil](http://kx.com/q/l32/Regards,Kamil)\</ram\_bollu\>

---

<div class="post-metadata">

**Author:** ![RB1](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@RB1](https://forum.kx.com/u/RB1)\
**Post date:** [March 22, 2011, 6:18pm UTC](https://forum.kx.com/t/calling-q-in-c-sample-program-steps/7059/5 "2011-03-22T18:18:00Z")

</div>

Thanks Kamil. It is just opening the file and not allowing medownload.I am not sure I can copy the object file by select all and prepare mylocal copy.It is bit strange to link with c.o, an object file rather than .so.Thanks for letting me know.On Mar 17, 1:22?am, Kamil Ja?kiewicz \<jaskiewicz.ka…\>wrote:\> On 16 March 2011 21:19, RB \<ram\_bo…\> wrote:\> Thank you Fintan. I started to write a program, it seems it needs to\> \> link with c.o file, how can I download that object file, there is no\> \> option to download this file from any location. Is there a way?.\> \> Thanks for letting me know.\>\> Here is for linux 32-bit:[http://kx.com/q/l32/&gt;&gt](http://kx.com/q/l32/&gt;&gt); Regards,\> Kamil\</ram\_bo…\>\</jaskiewicz.ka…\>

---

<div class="post-metadata">

**Author:** ![Kamil\_Jaskiewic](https://avatars.discourse-cdn.com/v4/letter/k/43a26b/32.png) [@Kamil\_Jaskiewic](https://forum.kx.com/u/Kamil_Jaskiewic)\
**Post date:** [March 22, 2011, 9:50pm UTC](https://forum.kx.com/t/calling-q-in-c-sample-program-steps/7059/6 "2011-03-22T21:50:00Z")

</div>

On 22 March 2011 19:18, RB \<ram\_bollu\> wrote:  
\> Thanks Kamil. It is just opening the file and not allowing me  
\> download.  
\> I am not sure I can copy the object file by select all and prepare my  
\> local copy.  
Just use “Save Link As” option in your web browser.  
  
\> It is bit strange to link with c.o, an object file rather than .so.  
I haven’t seen shared libraries for linux (for w32 and w64 you have  
c.dll). But you can link your program statically with c.o (then you  
don’t need shared libraries in your system, all required functions are  
already in your program).  
  
\> Thanks for letting me know.  
\>  
\> On Mar 17, 1:22=C2=A0am, Kamil Ja=C5=9Bkiewicz \<jaskiewicz.ka…\>m\>  
\> wrote:  
\>\> On 16 March 2011 21:19, RB \<ram\_bo…\> wrote:\> Thank you Fin=  
tan. I started to write a program, it seems it needs to  
\>\> \> link with c.o file, how can I download that object file, there is no  
\>\> \> option to download this file from any location. Is there a way?.  
\>\> \> Thanks for letting me know.  
\>\>  
\>\> Here is for linux 32-bit:[http://kx.com/q/l32/](http://kx.com/q/l32/)  
\>\>  
\>\> Regards,  
\>\> Kamil  
\>  
\> –  
\>

Submitted via Google Groups\</ram\_bo…\>\</jaskiewicz.ka…\>\</ram\_bollu\>

---

<div class="post-metadata">

**Author:** ![RB1](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@RB1](https://forum.kx.com/u/RB1)\
**Post date:** [March 23, 2011, 7:20pm UTC](https://forum.kx.com/t/calling-q-in-c-sample-program-steps/7059/7 "2011-03-23T19:20:00Z")

</div>

Thank you Kamil. Progressed I guess. But I get new problems now:c.o: In function `t1':c.c:(.text+0x1741): undefined reference to `pthread\_create’/home/RB/c.o: In function `ul':c.c:(.text+0x176c): undefined reference to `pthread\_rwlock\_unlock’/home/RB/c.o: In function `wl':c.c:(.text+0x179c): undefined reference to `pthread\_rwlock\_wrlock’/home/RB/c.o: In function `rl':c.c:(.text+0x17cc): undefined reference to `pthread\_rwlock\_rdlock’/home/RB/c.o: In function `mi0':c.c:(.text+0x369e): undefined reference to `pthread\_rwlock\_init’c.c:(.text+0x36a6): undefined reference to `pthread_mutexattr_init'c.c:(.text+0x36b6): undefined reference to `pthread\_mutexattr\_settype’collect2: ld returned 1 exit statussorry to take too much help from you.On Mar 17, 1:19?am, RB \<ram\_bo…\> wrote:\> Thank you Fintan. I started to write a program, it seems it needs to\> link with c.o file, how can I download that object file, there is no\> option to download this file from any location. Is there a way?.\> Thanks for letting me know.\>\> On Mar 14, 5:41?am, Fintan Quill \<fint…\> wrote:\>\> \> Hello,\>\> \> This is a good place to start:\>\> \>[https://code.kx.com/trac/wiki/Cookbook/InterfacingWithC](https://code.kx.com/trac/wiki/Cookbook/InterfacingWithC)(user/pass:\> \> anonymous/anonymous.\>\> \> Regards,\>\> \> Fintan.\>\> \> On Sun, Mar 13, 2011 at 5:31 AM, RB \<ram\_bo…\> wrote:\> \> \> Could somebody help me in getting some steps in calling q from C++. I\> \> \> am a learner and some direction is very much appreciated. I got q\> \> \> evaluation copied onto unbuntu. I want to link that with C++ from\> \> \> eclipse. Thanks for your time and help.\>\> \> \> –\> \> \>

Submitted via Google Groups\</ram\_bo…\>\</fint…\>\</ram\_bo…\>

---

<div class="post-metadata">

**Author:** ![charlie1](https://avatars.discourse-cdn.com/v4/letter/c/ec9cab/32.png) [@charlie1](https://forum.kx.com/u/charlie1)\
**Post date:** [March 23, 2011, 7:22pm UTC](https://forum.kx.com/t/calling-q-in-c-sample-program-steps/7059/8 "2011-03-23T19:22:00Z")

</div>

it needs to link with the pthread library

e.g.

gcc … -pthread

---

<div class="post-metadata">

**Author:** ![RB1](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@RB1](https://forum.kx.com/u/RB1)\
**Post date:** [March 26, 2011, 5:59pm UTC](https://forum.kx.com/t/calling-q-in-c-sample-program-steps/7059/9 "2011-03-26T17:59:00Z")

</div>

Thanks Charles, it worked.I wanted to print ‘a’ from below code to console like cout \<\< a.Basically how can I access a as part of my C++ code.int c = khpu(“localhost”, 1234 ,“rb:rb”); // Connect to a Kdb+ serveron the localhost port 1234 . k(-c,“a:2+2”,(K)0);Thanks again.On Mar 24, 12:22?am, Charles Skelton \<char…\> wrote:\> it needs to link with the pthread library\>\> e.g.\>\> gcc … -pthread\>\> On Wed, Mar 23, 2011 at 8:20 PM, RB \<ram\_bo…\> wrote:\> \> Thank you Kamil. Progressed I guess. But I get new problems now:\> \> c.o: In function `t1':&gt; &gt; c.c:(.text+0x1741): undefined reference to `pthread\_create’\> \> /home/RB/c.o: In function `ul':&gt; &gt; c.c:(.text+0x176c): undefined reference to `pthread\_rwlock\_unlock’\> \> /home/RB/c.o: In function `wl':&gt; &gt; c.c:(.text+0x179c): undefined reference to `pthread\_rwlock\_wrlock’\> \> /home/RB/c.o: In function `rl':&gt; &gt; c.c:(.text+0x17cc): undefined reference to `pthread\_rwlock\_rdlock’\> \> /home/RB/c.o: In function `mi0':&gt; &gt; c.c:(.text+0x369e): undefined reference to `pthread\_rwlock\_init’\> \> c.c:(.text+0x36a6): undefined reference to `pthread_mutexattr_init'&gt; &gt; c.c:(.text+0x36b6): undefined reference to `pthread\_mutexattr\_settype’\> \> collect2: ld returned 1 exit status\>\> \> sorry to take too much help from you.\>\> \> On Mar 17, 1:19 am, RB \<ram\_bo…\> wrote:\> \> \> Thank you Fintan. I started to write a program, it seems it needs to\> \> \> link with c.o file, how can I download that object file, there is no\> \> \> option to download this file from any location. Is there a way?.\> \> \> Thanks for letting me know.\>\> \> \> On Mar 14, 5:41 am, Fintan Quill \<fint…\> wrote:\>\> \> \> \> Hello,\>\> \> \> \> This is a good place to start:\>\> \> \> \>[https://code.kx.com/trac/wiki/Cookbook/InterfacingWithC](https://code.kx.com/trac/wiki/Cookbook/InterfacingWithC)(user/pass:\> \> \> \> anonymous/anonymous.\>\> \> \> \> Regards,\>\> \> \> \> Fintan.\>\> \> \> \> On Sun, Mar 13, 2011 at 5:31 AM, RB \<ram\_bo…\> wrote:\> \> \> \> \> Could somebody help me in getting some steps in calling q from C++. I\> \> \> \> \> am a learner and some direction is very much appreciated. I got q\> \> \> \> \> evaluation copied onto unbuntu. I want to link that with C++ from\> \> \> \> \> eclipse. Thanks for your time and help.\>\> \> \> \> \> –\> \> \> \> \> You received this message because you are subscribed to the Google\> \> Groups\> \> \> \> \> “Kdb+ Personal Developers” group.\> \> \> \> \> To post to this group, send email to\> \> [personal-kdbplus@googlegroups.com](mailto:personal-kdbplus@googlegroups.com).\> \> \> \> \> To unsubscribe from this group, send email to\> \> \> \> \> [personal-kdbplus+unsubscribe@googlegroups.com](mailto:personal-kdbplus+unsubscribe@googlegroups.com).\> \> \> \> \> For more options, visit this group at\> \> \> \> \>[http://groups.google.com/group/personal-kdbplus?hl=en.&gt;&gt](http://groups.google.com/group/personal-kdbplus?hl=en.&gt;&gt); \> –\> \>

Submitted via Google Groups\</ram\_bo…\>\</fint…\>\</ram\_bo…\>\</ram\_bo…\>\</char…\>

---

<div class="post-metadata">

**Author:** ![RB1](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@RB1](https://forum.kx.com/u/RB1)\
**Post date:** [March 28, 2011, 7:08pm UTC](https://forum.kx.com/t/calling-q-in-c-sample-program-steps/7059/10 "2011-03-28T19:08:00Z")

</div>

All below statements working fine, when I see the data from browser: int c = khpu(“localhost”, 1234 ,“vishist:vishist”); // Connect to aKdb+ server on the localhost port 1234 . k(-c,"d: `name`salary! (`tom`dick`harry;30 30 35)",(K)0); k(-c,"f:flip d",(K)0); k(-c,"`f insert(`rem;40)",(K)0);//insertBut, how to get data out from q to C++ so that I can use the data aspart of C++ code.Thanks for the help.On Mar 26, 10:59?pm, RB <ram_bo...> wrote:&gt; Thanks Charles, it worked.&gt; I wanted to print 'a' from below code to console like cout &lt;&lt; a.&gt; Basically how can I access a as part of my C++ code.&gt;&gt; int c = khpu("localhost", 1234 ,"rb:rb"); // Connect to a Kdb+ server&gt; on the localhost port 1234 .&gt; ? ? ? ? k(-c,"a:2+2",(K)0);&gt;&gt; Thanks again.&gt;&gt; On Mar 24, 12:22?am, Charles Skelton <char...> wrote:&gt;&gt; &gt; it needs to link with the pthread library&gt;&gt; &gt; e.g.&gt;&gt; &gt; gcc .... -pthread&gt;&gt; &gt; On Wed, Mar 23, 2011 at 8:20 PM, RB <ram_bo...> wrote:&gt; &gt; &gt; Thank you Kamil. Progressed I guess. But I get new problems now:&gt; &gt; &gt; c.o: In function `t1’:\> \> \> c.c:(.text+0x1741): undefined reference to `pthread_create'&gt; &gt; &gt; /home/RB/c.o: In function `ul’:\> \> \> c.c:(.text+0x176c): undefined reference to `pthread_rwlock_unlock'&gt; &gt; &gt; /home/RB/c.o: In function `wl’:\> \> \> c.c:(.text+0x179c): undefined reference to `pthread_rwlock_wrlock'&gt; &gt; &gt; /home/RB/c.o: In function `rl’:\> \> \> c.c:(.text+0x17cc): undefined reference to `pthread_rwlock_rdlock'&gt; &gt; &gt; /home/RB/c.o: In function `mi0’:\> \> \> c.c:(.text+0x369e): undefined reference to `pthread_rwlock_init'&gt; &gt; &gt; c.c:(.text+0x36a6): undefined reference to `pthread\_mutexattr\_init’\> \> \> c.c:(.text+0x36b6): undefined reference to `pthread\_mutexattr\_settype’\> \> \> collect2: ld returned 1 exit status\>\> \> \> sorry to take too much help from you.\>\> \> \> On Mar 17, 1:19 am, RB \<ram\_bo…\> wrote:\> \> \> \> Thank you Fintan. I started to write a program, it seems it needs to\> \> \> \> link with c.o file, how can I download that object file, there is no\> \> \> \> option to download this file from any location. Is there a way?.\> \> \> \> Thanks for letting me know.\>\> \> \> \> On Mar 14, 5:41 am, Fintan Quill \<fint…\> wrote:\>\> \> \> \> \> Hello,\>\> \> \> \> \> This is a good place to start:\>\> \> \> \> \>[https://code.kx.com/trac/wiki/Cookbook/InterfacingWithC](https://code.kx.com/trac/wiki/Cookbook/InterfacingWithC)(user/pass:\> \> \> \> \> anonymous/anonymous.\>\> \> \> \> \> Regards,\>\> \> \> \> \> Fintan.\>\> \> \> \> \> On Sun, Mar 13, 2011 at 5:31 AM, RB \<ram\_bo…\> wrote:\> \> \> \> \> \> Could somebody help me in getting some steps in calling q from C++. I\> \> \> \> \> \> am a learner and some direction is very much appreciated. I got q\> \> \> \> \> \> evaluation copied onto unbuntu. I want to link that with C++ from\> \> \> \> \> \> eclipse. Thanks for your time and help.\>\> \> \> \> \> \> –\> \> \> \> \> \> You received this message because you are subscribed to the Google\> \> \> Groups\> \> \> \> \> \> “Kdb+ Personal Developers” group.\> \> \> \> \> \> To post to this group, send email to\> \> \> [personal-kdbplus@googlegroups.com](mailto:personal-kdbplus@googlegroups.com).\> \> \> \> \> \> To unsubscribe from this group, send email to\> \> \> \> \> \> [personal-kdbplus+unsubscribe@googlegroups.com](mailto:personal-kdbplus+unsubscribe@googlegroups.com).\> \> \> \> \> \> For more options, visit this group at\> \> \> \> \> \>[http://groups.google.com/group/personal-kdbplus?hl=en.&gt;&gt](http://groups.google.com/group/personal-kdbplus?hl=en.&gt;&gt); \> \> –\> \> \>

Submitted via Google Groups\</ram\_bo…\>\</fint…\>\</ram\_bo…\>\</ram\_bo…\>\</char…\>\</ram\_bo…\>

---

<div class="post-metadata">

**Author:** ![RB1](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@RB1](https://forum.kx.com/u/RB1)\
**Post date:** [March 31, 2011, 10:31pm UTC](https://forum.kx.com/t/calling-q-in-c-sample-program-steps/7059/11 "2011-03-31T22:31:00Z")

</div>

Could somebody experts over there help me please?.thanks a lot.On Mar 28, 11:08?pm, RB \<ram\_bo…\> wrote:\> All below statements working fine, when I see the data from browser:\>\> ? ? ? ? int c = khpu(“localhost”, 1234 ,“vishist:vishist”); // Connect to a\> Kdb+ server on the localhost port 1234 .\>\> ? ? ? ? k(-c,"d: `name`salary! (`tom`dick`harry;30 30 35)",(K)0);&gt; ? ? ? ? k(-c,"f:flip d",(K)0);&gt; ? ? ? ? k(-c,"`f insert(`rem;40)",(K)0);//insert&gt;&gt; But, how to get data out from q to C++ so that I can use the data as&gt; part of C++ code.&gt;&gt; Thanks for the help.&gt;&gt; On Mar 26, 10:59?pm, RB <ram_bo...> wrote:&gt;&gt; &gt; Thanks Charles, it worked.&gt; &gt; I wanted to print 'a' from below code to console like cout &lt;&lt; a.&gt; &gt; Basically how can I access a as part of my C++ code.&gt;&gt; &gt; int c = khpu("localhost", 1234 ,"rb:rb"); // Connect to a Kdb+ server&gt; &gt; on the localhost port 1234 .&gt; &gt; ? ? ? ? k(-c,"a:2+2",(K)0);&gt;&gt; &gt; Thanks again.&gt;&gt; &gt; On Mar 24, 12:22?am, Charles Skelton <char...> wrote:&gt;&gt; &gt; &gt; it needs to link with the pthread library&gt;&gt; &gt; &gt; e.g.&gt;&gt; &gt; &gt; gcc .... -pthread&gt;&gt; &gt; &gt; On Wed, Mar 23, 2011 at 8:20 PM, RB <ram_bo...> wrote:&gt; &gt; &gt; &gt; Thank you Kamil. Progressed I guess. But I get new problems now:&gt; &gt; &gt; &gt; c.o: In function `t1’:\> \> \> \> c.c:(.text+0x1741): undefined reference to `pthread_create'&gt; &gt; &gt; &gt; /home/RB/c.o: In function `ul’:\> \> \> \> c.c:(.text+0x176c): undefined reference to `pthread_rwlock_unlock'&gt; &gt; &gt; &gt; /home/RB/c.o: In function `wl’:\> \> \> \> c.c:(.text+0x179c): undefined reference to `pthread_rwlock_wrlock'&gt; &gt; &gt; &gt; /home/RB/c.o: In function `rl’:\> \> \> \> c.c:(.text+0x17cc): undefined reference to `pthread_rwlock_rdlock'&gt; &gt; &gt; &gt; /home/RB/c.o: In function `mi0’:\> \> \> \> c.c:(.text+0x369e): undefined reference to `pthread_rwlock_init'&gt; &gt; &gt; &gt; c.c:(.text+0x36a6): undefined reference to `pthread\_mutexattr\_init’\> \> \> \> c.c:(.text+0x36b6): undefined reference to `pthread\_mutexattr\_settype’\> \> \> \> collect2: ld returned 1 exit status\>\> \> \> \> sorry to take too much help from you.\>\> \> \> \> On Mar 17, 1:19 am, RB \<ram\_bo…\> wrote:\> \> \> \> \> Thank you Fintan. I started to write a program, it seems it needs to\> \> \> \> \> link with c.o file, how can I download that object file, there is no\> \> \> \> \> option to download this file from any location. Is there a way?.\> \> \> \> \> Thanks for letting me know.\>\> \> \> \> \> On Mar 14, 5:41 am, Fintan Quill \<fint…\> wrote:\>\> \> \> \> \> \> Hello,\>\> \> \> \> \> \> This is a good place to start:\>\> \> \> \> \> \>[https://code.kx.com/trac/wiki/Cookbook/InterfacingWithC](https://code.kx.com/trac/wiki/Cookbook/InterfacingWithC)(user/pass:\> \> \> \> \> \> anonymous/anonymous.\>\> \> \> \> \> \> Regards,\>\> \> \> \> \> \> Fintan.\>\> \> \> \> \> \> On Sun, Mar 13, 2011 at 5:31 AM, RB \<ram\_bo…\> wrote:\> \> \> \> \> \> \> Could somebody help me in getting some steps in calling q from C++. I\> \> \> \> \> \> \> am a learner and some direction is very much appreciated. I got q\> \> \> \> \> \> \> evaluation copied onto unbuntu. I want to link that with C++ from\> \> \> \> \> \> \> eclipse. Thanks for your time and help.\>\> \> \> \> \> \> \> –\> \> \> \> \> \> \> You received this message because you are subscribed to the Google\> \> \> \> Groups\> \> \> \> \> \> \> “Kdb+ Personal Developers” group.\> \> \> \> \> \> \> To post to this group, send email to\> \> \> \> [personal-kdbplus@googlegroups.com](mailto:personal-kdbplus@googlegroups.com).\> \> \> \> \> \> \> To unsubscribe from this group, send email to\> \> \> \> \> \> \> [personal-kdbplus+unsubscribe@googlegroups.com](mailto:personal-kdbplus+unsubscribe@googlegroups.com).\> \> \> \> \> \> \> For more options, visit this group at\> \> \> \> \> \> \>[http://groups.google.com/group/personal-kdbplus?hl=en.&gt;&gt](http://groups.google.com/group/personal-kdbplus?hl=en.&gt;&gt); \> \> \> –\> \> \> \>

Submitted via Google Groups\</ram\_bo…\>\</fint…\>\</ram\_bo…\>\</ram\_bo…\>\</char…\>\</ram\_bo…\>\</ram\_bo…\>

---

<div class="post-metadata">

**Author:** ![Alex\_Demin1](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@Alex\_Demin1](https://forum.kx.com/u/Alex_Demin1)\
**Post date:** [April 15, 2011, 6:58pm UTC](https://forum.kx.com/t/calling-q-in-c-sample-program-steps/7059/12 "2011-04-15T18:58:00Z")

</div>

cout\<i;“a:2+2;a” will do the addition and return value of a as pinter to k0struct or K to the caller.k() will return this pointer K object and knowing the 2+2 is an intyou can address it via -\>iOn Mar 26, 1:59?pm, RB \<ram\_bo…\> wrote:\> Thanks Charles, it worked.\> I wanted to print ‘a’ from below code to console like cout \<\< a.\> Basically how can I access a as part of my C++ code.\>\> intc= khpu(“localhost”, 1234 ,“rb:rb”); // Connect to a Kdb+ server\> on the localhost port 1234 .\> ? ? ? ?k(-c,“a:2+2”,(K)0);\>\> Thanks again.\>\> On Mar 24, 12:22?am, Charles Skelton \<char…\> wrote:\>\>\>\> \> it needs to link with the pthread library\>\> \> e.g.\>\> \> gcc … -pthread\>\> \> On Wed, Mar 23, 2011 at 8:20 PM, RB \<ram\_bo…\> wrote:\> \> \> Thank you Kamil. Progressed I guess. But I get new problems now:\> \> \> c.o: In function `t1':&gt; &gt; &gt; c.c:(.text+0x1741): undefined reference to `pthread\_create’\> \> \> /home/RB/c.o: In function `ul':&gt; &gt; &gt; c.c:(.text+0x176c): undefined reference to `pthread\_rwlock\_unlock’\> \> \> /home/RB/c.o: In function `wl':&gt; &gt; &gt; c.c:(.text+0x179c): undefined reference to `pthread\_rwlock\_wrlock’\> \> \> /home/RB/c.o: In function `rl':&gt; &gt; &gt; c.c:(.text+0x17cc): undefined reference to `pthread\_rwlock\_rdlock’\> \> \> /home/RB/c.o: In function `mi0':&gt; &gt; &gt; c.c:(.text+0x369e): undefined reference to `pthread\_rwlock\_init’\> \> \> c.c:(.text+0x36a6): undefined reference to `pthread_mutexattr_init'&gt; &gt; &gt; c.c:(.text+0x36b6): undefined reference to `pthread\_mutexattr\_settype’\> \> \> collect2: ld returned 1 exit status\>\> \> \> sorry to take too much help from you.\>\> \> \> On Mar 17, 1:19 am, RB \<ram\_bo…\> wrote:\> \> \> \> Thank you Fintan. I started to write a program, it seems it needs to\> \> \> \> link with c.o file, how can I download that object file, there is no\> \> \> \> option to download this file from any location. Is there a way?.\> \> \> \> Thanks for letting me know.\>\> \> \> \> On Mar 14, 5:41 am, Fintan Quill \<fint…\> wrote:\>\> \> \> \> \> Hello,\>\> \> \> \> \> This is a good place to start:\>\> \> \> \> \>[https://code.kx.com/trac/wiki/Cookbook/InterfacingWithC](https://code.kx.com/trac/wiki/Cookbook/InterfacingWithC)(user/pass:\> \> \> \> \> anonymous/anonymous.\>\> \> \> \> \> Regards,\>\> \> \> \> \> Fintan.\>\> \> \> \> \> On Sun, Mar 13, 2011 at 5:31 AM, RB \<ram\_bo…\> wrote:\> \> \> \> \> \> Could somebody help me in getting some steps incallingq from C++. I\> \> \> \> \> \> am a learner and some direction is very much appreciated. I got q\> \> \> \> \> \> evaluation copied onto unbuntu. I want to link that with C++ from\> \> \> \> \> \> eclipse. Thanks for your time and help.\>\> \> \> \> \> \> –\> \> \> \> \> \> You received this message because you are subscribed to the Google\> \> \> Groups\> \> \> \> \> \> “Kdb+ Personal Developers” group.\> \> \> \> \> \> To post to this group, send email to\> \> \> [personal-kdbplus@googlegroups.com](mailto:personal-kdbplus@googlegroups.com).\> \> \> \> \> \> To unsubscribe from this group, send email to\> \> \> \> \> \> [personal-kdbplus+unsubscribe@googlegroups.com](mailto:personal-kdbplus+unsubscribe@googlegroups.com).\> \> \> \> \> \> For more options, visit this group at\> \> \> \> \> \>[http://groups.google.com/group/personal-kdbplus?hl=en.&gt;&gt](http://groups.google.com/group/personal-kdbplus?hl=en.&gt;&gt); \> \> –\> \> \>

Submitted via Google Groups\</ram\_bo…\>\</fint…\>\</ram\_bo…\>\</ram\_bo…\>\</char…\>\</ram\_bo…\>
