calling q in C++ - sample program - steps

576 views
Skip to first unread message

RB

unread,
Mar 13, 2011, 5:31:32 AM3/13/11
to Kdb+ Personal Developers
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.

Fintan Quill

unread,
Mar 13, 2011, 8:41:37 PM3/13/11
to personal...@googlegroups.com
Hello,

This is a good place to start:


Regards,

Fintan.


--
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...@googlegroups.com.
To unsubscribe from this group, send email to personal-kdbpl...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/personal-kdbplus?hl=en.


Kamil Jaśkiewicz

unread,
Mar 16, 2011, 4:22:52 PM3/16/11
to personal...@googlegroups.com
On 16 March 2011 21:19, RB <ram_...@hotmail.com> 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

RB

unread,
Mar 16, 2011, 4:19:41 PM3/16/11
to Kdb+ Personal Developers
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...@gmail.com> wrote:
> Hello,
>
> This is a good place to start:
>
> https://code.kx.com/trac/wiki/Cookbook/InterfacingWithC(user/pass:
> anonymous/anonymous.
>
> Regards,
>
> Fintan.
>

RB

unread,
Mar 22, 2011, 2:18:42 PM3/22/11
to Kdb+ Personal Developers
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.
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...@gmail.com>
wrote:
> On 16 March 2011 21:19, RB <ram_bo...@hotmail.com> wrote:> Thank you Fintan. I started to write a program, it seems it needs to

Kamil Jaśkiewicz

unread,
Mar 22, 2011, 5:50:02 PM3/22/11
to personal...@googlegroups.com
On 22 March 2011 19:18, RB <ram_...@hotmail.com> 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 am, Kamil Jaśkiewicz <jaskiewicz.ka...@gmail.com>
> wrote:
>> On 16 March 2011 21:19, RB <ram_bo...@hotmail.com> 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
>

RB

unread,
Mar 23, 2011, 3:20:19 PM3/23/11
to Kdb+ Personal Developers
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 status

sorry to take too much help from you.

Charles Skelton

unread,
Mar 23, 2011, 3:22:23 PM3/23/11
to personal...@googlegroups.com, RB
it needs to link with the pthread library

e.g.

gcc .... -pthread

RB

unread,
Mar 26, 2011, 1:59:01 PM3/26/11
to Kdb+ Personal Developers
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+ server
on the localhost port 1234 .
k(-c,"a:2+2",(K)0);

Thanks again.

On Mar 24, 12:22 am, Charles Skelton <char...@kx.com> wrote:
> it needs to link with the pthread library
>
> e.g.
>
> gcc .... -pthread
>

RB

unread,
Mar 28, 2011, 2:08:00 PM3/28/11
to Kdb+ Personal Developers
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);
k(-c,"f:flip d",(K)0);
k(-c,"`f insert(`rem;40)",(K)0);//insert

But, how to get data out from q to C++ so that I can use the data as
part of C++ code.

Thanks for the help.

RB

unread,
Mar 31, 2011, 5:31:15 PM3/31/11
to Kdb+ Personal Developers
Could somebody experts over there help me please?.

thanks a lot.

Alex Demin

unread,
Apr 15, 2011, 1:58:54 PM4/15/11
to Kdb+ Personal Developers
cout<<k(-c,"a:2+2;a",(K)0)->i;
"a:2+2;a" will do the addition and return value of a as pinter to k0
struct or K to the caller.
k() will return this pointer K object and knowing the 2+2 is an int
you can address it via ->i



On Mar 26, 1:59 pm, RB <ram_bo...@hotmail.com> 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
> > > > > > 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...@googlegroups.com.
> > > > > > To unsubscribe from this group, send email to
> > > > > > personal-kdbpl...@googlegroups.com.
> > > > > > For more options, visit this group at
> > > > > >http://groups.google.com/group/personal-kdbplus?hl=en.
>
> > > --
> > > 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...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > personal-kdbpl...@googlegroups.com.
> > > For more options, visit this group at
> > >http://groups.google.com/group/personal-kdbplus?hl=en.- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages