# problem when interfacing with C problems on win32

**URL:** <https://forum.kx.com/t/problem-when-interfacing-with-c-problems-on-win32/6675>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [July 22, 2010, 4:30pm UTC](https://forum.kx.com/t/problem-when-interfacing-with-c-problems-on-win32/6675 "2010-07-22T16:30:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sergey\_Kolos](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@Sergey\_Kolos](https://forum.kx.com/u/Sergey_Kolos)\
**Post date:** [July 22, 2010, 4:30pm UTC](https://forum.kx.com/t/problem-when-interfacing-with-c-problems-on-win32/6675/1 "2010-07-22T16:30:00Z")

</div>

I am trying to add my C functions to q. I created dll project in  
Visual Studio. To build dll I had to link to c.lib (with corresponding  
c.dll). When I do this, I get complaint from linker that function krr  
is not found (which is not surprising, since krr is not in c.def  
file). So I also tried to link with c.o and c.obj. When I link with  
c.o a call to my function crashes. The function looks as follows:

\_\_declspec(dllexport) K func()  
{  
K res = ktn(KF,2);  
return res;  
}

The call to the function crashes at ktn(KF,2) when linking to c.o, but  
doesn’t crash when linking to c.lib or c.obj.

However the function crashes when linking with any of c.lib, c.o, or  
c.obj if I change it to the following:

\_\_declspec(dllexport) K func()  
{  
return krr(ss(“result”));  
}

or

\_\_declspec(dllexport) K func()  
{  
return ks(“result”);  
}

When the dll crashes I get unhandled exception message box with  
following message:  
“Unhandled exception at 0x10013ee8 (q\_fann.dll) in q: 0xC0000005:  
Access violation reading location 0x00000004.”

Note that calling krr or ks functions on linux does not produce any  
problems.

So the question I have is: Does any workaround exist to resolve these  
problems?

Thanks
