embed q in c without khp dependency

Hi Guys,

I used to be able to embed q in c by calling k(0,…), but now it doesn’t seem to work. ?What is the magic to initialize q and call k() without needing to connect to a server?

http://code.kx.com/wiki/Cookbook/InterfacingWithC

jack@deb:~/q$ cat t.c

#include<stdio.h>

#include"k.h"

int main(){K x,y;int cc=khp(“localhost”,0);

?x=k(0,(S)0);

?x=k(0,“1+2”,(K)0);

?O(“%d %s\n”,xt,xs);

?fflush(stdout);

?return 0;

}

don’t know what you by embedding q in c.
it used to be possible to embed k2/3 runtime in a C program but not k4/q.

the only thing you can do now is to embed the comm part of k4 in c
program and call and pass data between you app and a q server.

khp() is used to initialize the comm library and open a connection to q server.
if you call it with khp(“”,0) it just does the initialization and
skips the connection part.
in this context k(0,…) is meaningless as there is no interpreter
associated with the comm library.
k(0,.. can be called only from external libraries embedded (loaded) in q.

felix

2012/10/13 Jack Andrews :
> Hi Guys,
>
> I used to be able to embed q in c by calling k(0,…), but now it doesn’t
> seem to work. What is the magic to initialize q and call k() without
> needing to connect to a server?
>
> http://code.kx.com/wiki/Cookbook/InterfacingWithC
>
> jack@deb:~/q$ cat t.c
> #include<stdio.h>
> #include"k.h"
>
> int main(){K x,y;int cc=khp(“localhost”,0);
> x=k(0,(S)0);
> x=k(0,“1+2”,(K)0);
> O(“%d %s\n”,xt,xs);
> fflush(stdout);
> return 0;
> }
>
> –
>

Submitted via Google Groups</stdio.h>