# cannot load dll

**URL:** <https://forum.kx.com/t/cannot-load-dll/5804>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [September 24, 2008, 4:49pm UTC](https://forum.kx.com/t/cannot-load-dll/5804 "2008-09-24T16:49:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dbtouch](https://avatars.discourse-cdn.com/v4/letter/d/9de053/32.png) [@dbtouch](https://forum.kx.com/u/dbtouch)\
**Post date:** [September 24, 2008, 4:49pm UTC](https://forum.kx.com/t/cannot-load-dll/5804/1 "2008-09-24T16:49:00Z")

</div>

Dear KDB Users,I cannot load DLL in q console on windows. I suspect that I buildexample dll (a.dll) using MS VC8.0 and it may not be compatible withKDB+. Please advise.My KDB version is:KDB+ 2.4 2008.03.31 Copyright (C) 1993-2008 Kx Systemsw32/ 4()core 2047MB XYZ abcd 10.27.137.157 TIMEOUT 2009.04.01And the example program is:// a.c// w32\>cl /LD ..\c\a.c a.def q.lib// l32\>/usr/local/gcc-3.3.2/bin/gcc -shared ../c/a.c -o a.so// s32\>/usr/local/gcc-3.3.2/bin/gcc -G ../c/a.c -o a.so#include"k.h"K f(K x){return ki(x-\>i+1);} // q calls cK g(K x){return k(0,“1+”,r1(x),0);} // c calls q/\*f:`a 2:(`f;1)g:`a 2:(`g;1)f 2g 3\*/a.def file is:EXPORTS fEXPORTS gThe build command is:cl -IC:\q\w32\src -I"C:\msft VS8\VC\include" /LD a.c a.def C:\q\w32\sdk\q.lib /link “C:\msft VS8\VC\lib\LIBCMT.lib” “C:\msft VS8\VC\lib\OLDNAMES.lib” "C:\msft VS8\VC\lib\kernel32.lib"When I loaded a.dll in KDB console, I got error:q)f:`a 2:(`f;1)'The specified module could not be found.dbtouch

---

<div class="post-metadata">

**Author:** ![Lindqvist](https://avatars.discourse-cdn.com/v4/letter/l/b4bc9f/32.png) [@Lindqvist](https://forum.kx.com/u/Lindqvist)\
**Post date:** [September 24, 2008, 9:13pm UTC](https://forum.kx.com/t/cannot-load-dll/5804/2 "2008-09-24T21:13:00Z")

</div>

If you look at the page [https://code.kx.com/trac/wiki/Cookbook/ExtendingWithCyou](https://code.kx.com/trac/wiki/Cookbook/ExtendingWithCyou) will see the phrase:"The resulting binary should be placed in the same directory as the qexecutable."If my memory serves my correct, Q will look for the library to load inthe QHOME directory (which is where the q binary is located).H?kan

---

<div class="post-metadata">

**Author:** ![felix1](https://avatars.discourse-cdn.com/v4/letter/f/3e96dc/32.png) [@felix1](https://forum.kx.com/u/felix1)\
**Post date:** [September 25, 2008, 4:43pm UTC](https://forum.kx.com/t/cannot-load-dll/5804/3 "2008-09-25T16:43:00Z")

</div>

X-Mailer: Apple Mail (2.929.2)well, there are few places where q is looking to load a dll:1. working directory2. $QHOME/ (win32 is $QHOME/w32 and in most cases QHOME is c:\q)3. if the dll has an absolute path, q will load it straight in.felixOn 24 Sep 2008, at 23:13, Lindqvist wrote:\>\> If you look at the page [https://code.kx.com/trac/wiki/Cookbook/ExtendingWithC&gt](https://code.kx.com/trac/wiki/Cookbook/ExtendingWithC&gt); you will see the phrase:\>\> “The resulting binary should be placed in the same directory as the q\> executable.”\>\> If my memory serves my correct, Q will look for the library to load in\> the QHOME directory (which is where the q binary is located).\>\>\> H?kan\> \>

---

<div class="post-metadata">

**Author:** ![dbtouch](https://avatars.discourse-cdn.com/v4/letter/d/9de053/32.png) [@dbtouch](https://forum.kx.com/u/dbtouch)\
**Post date:** [September 26, 2008, 3:08am UTC](https://forum.kx.com/t/cannot-load-dll/5804/4 "2008-09-26T03:08:00Z")

</div>

It turned out my guess is correct: KDB+ does not support VC 8.0.dbtouchOn Sep 24, 11:49?am, dbtouch \<dbto…\> wrote:\> Dear KDB Users,\>\> I cannot load DLL in q console on windows. I suspect that I build\> example dll (a.dll) using MS VC8.0 and it may not be compatible with\> KDB+. Please advise.\>\> My KDB version is:\>\> KDB+ 2.4 2008.03.31 Copyright (C) 1993-2008 Kx Systems\> w32/ 4()core 2047MB XYZ abcd 10.27.137.157 TIMEOUT 2009.04.01\>\> And the example program is:\>\> // a.c\> // w32\>cl /LD ..\c\a.c a.def q.lib\> // l32\>/usr/local/gcc-3.3.2/bin/gcc -shared ../c/a.c -o a.so\> // s32\>/usr/local/gcc-3.3.2/bin/gcc -G ? ? ?../c/a.c -o a.so\>\> #include"k.h"\> K f(K x){return ki(x-\>i+1);} ?// q calls c\> K g(K x){return k(0,“1+”,r1(x),0);} // c calls q\>\> /\*\> f:`a 2:(`f;1)\> g:`a 2:(`g;1)\> f 2\> g 3\> \*/\>\> a.def file is:\> EXPORTS f\> EXPORTS g\>\> The build command is:\> cl -IC:\q\w32\src -I"C:\msft VS8\VC\include" /LD a.c a.def C:\q\w32\sdk\> \q.lib &gt; /link “C:\msft VS8\VC\lib\LIBCMT.lib” “C:\msft VS8\VC\lib\> \OLDNAMES.lib” “C:\msft VS8\VC\lib\kernel32.lib”\>\> When I loaded a.dll in KDB console, I got error:\>\> q)f:`a 2:(`f;1)\> 'The specified module could not be found.\>\> dbtouch\</dbto…\>

---

<div class="post-metadata">

**Author:** ![felix1](https://avatars.discourse-cdn.com/v4/letter/f/3e96dc/32.png) [@felix1](https://forum.kx.com/u/felix1)\
**Post date:** [September 26, 2008, 11:37pm UTC](https://forum.kx.com/t/cannot-load-dll/5804/5 "2008-09-26T23:37:00Z")

</div>

X-Mailer: Apple Mail (2.929.2)not the 32bit one.you can configure vc8 to use msvcrt6.dll instead of the default one.felixOn 26 Sep 2008, at 05:08, dbtouch wrote:\>\> It turned out my guess is correct: KDB+ does not support VC 8.0.\>\> dbtouch\>\> On Sep 24, 11:49 am, dbtouch \<dbto…\> wrote:\>\> Dear KDB Users,\>\>\>\> I cannot load DLL in q console on windows. I suspect that I build\>\> example dll (a.dll) using MS VC8.0 and it may not be compatible with\>\> KDB+. Please advise.\>\>\>\> My KDB version is:\>\>\>\> KDB+ 2.4 2008.03.31 Copyright (C) 1993-2008 Kx Systems\>\> w32/ 4()core 2047MB XYZ abcd 10.27.137.157 TIMEOUT 2009.04.01\>\>\>\> And the example program is:\>\>\>\> // a.c\>\> // w32\>cl /LD ..\c\a.c a.def q.lib\>\> // l32\>/usr/local/gcc-3.3.2/bin/gcc -shared ../c/a.c -o a.so\>\> // s32\>/usr/local/gcc-3.3.2/bin/gcc -G ../c/a.c -o a.so\>\>\>\> #include"k.h"\>\> K f(K x){return ki(x-\>i+1);} // q calls c\>\> K g(K x){return k(0,“1+”,r1(x),0);} // c calls q\>\>\>\> /\*\>\> f:`a 2:(`f;1)\>\> g:`a 2:(`g;1)\>\> f 2\>\> g 3\>\> \*/\>\>\>\> a.def file is:\>\> EXPORTS f\>\> EXPORTS g\>\>\>\> The build command is:\>\> cl -IC:\q\w32\src -I"C:\msft VS8\VC\include" /LD a.c a.def C:\q \>\> \w32\sdk\>\> \q.lib &gt;\> /link “C:\msft VS8\VC\lib\LIBCMT.lib” “C:\msft VS8\VC\lib\>\> \OLDNAMES.lib” “C:\msft VS8\VC\lib\kernel32.lib”\>\>\>\> When I loaded a.dll in KDB console, I got error:\>\>\>\> q)f:`a 2:(`f;1)\>\> 'The specified module could not be found.\>\>\>\> dbtouch\> \>\</dbto…\>
