# glfwGetKey call from user dll not working

**URL:** <https://discourse.glfw.org/t/glfwgetkey-call-from-user-dll-not-working/240>\
**Category:** support\
**Created:** [March 16, 2012, 11:50am UTC](https://discourse.glfw.org/t/glfwgetkey-call-from-user-dll-not-working/240 "2012-03-16T11:50:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [March 16, 2012, 11:50am UTC](https://discourse.glfw.org/t/glfwgetkey-call-from-user-dll-not-working/240/1 "2012-03-16T11:50:10Z")

</div>

**[mrdarkal](https://sourceforge.net/u/mrdarkal/)** wrote on [Friday, March 16, 2012](https://sourceforge.net/p/glfw/discussion/247562/thread/ff457641/#f171):

I copied a sample program form manual (the one that runs until escape key has  
been pressed). Everything works fine, if I call glfwGetKey form my exe  
module. But in my scenario, I have a dll project, where a class CControl is  
implemented (derived from interface IControl). CControl has a member  
function CControl::GetKey which is a stupid wrapper and happens to do the sole  
thing: return glfwGetKey(k), where k is an int passed to CControl::GetKey as  
argument. When I get (in my exe module) a pointer to CControl object, and  
when I call CControl::GetKey (insted of glfwGetKey), pressing escape key has  
no effect.

Any ideas?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [March 16, 2012, 11:53am UTC](https://discourse.glfw.org/t/glfwgetkey-call-from-user-dll-not-working/240/2 "2012-03-16T11:53:04Z")

</div>

**[elmindreda](https://sourceforge.net/u/elmindreda/)** wrote on [Friday, March 16, 2012](https://sourceforge.net/p/glfw/discussion/247562/thread/ff457641/#d473):

Did you define GLFW\_DLL?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [March 18, 2012, 12:36am UTC](https://discourse.glfw.org/t/glfwgetkey-call-from-user-dll-not-working/240/3 "2012-03-18T00:36:27Z")

</div>

**[mrdarkal](https://sourceforge.net/u/mrdarkal/)** wrote on [Sunday, March 18, 2012](https://sourceforge.net/p/glfw/discussion/247562/thread/ff457641/#b4a8):

Thanks for reply. Your advice helped me to solve my problem. I make my dll  
projects to use glfw.dll library (GLFW\_DLL defined before including  
glfw.h).

Apart from that, why statically linked glfw.lib to my dll doesn’t work?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [March 18, 2012, 12:48am UTC](https://discourse.glfw.org/t/glfwgetkey-call-from-user-dll-not-working/240/4 "2012-03-18T00:48:14Z")

</div>

**[elmindreda](https://sourceforge.net/u/elmindreda/)** wrote on [Sunday, March 18, 2012](https://sourceforge.net/p/glfw/discussion/247562/thread/ff457641/#9253):

What is it that doesn’t work? In what way doesn’t it work?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [March 18, 2012, 10:20pm UTC](https://discourse.glfw.org/t/glfwgetkey-call-from-user-dll-not-working/240/5 "2012-03-18T22:20:01Z")

</div>

**[mrdarkal](https://sourceforge.net/u/mrdarkal/)** wrote on [Sunday, March 18, 2012](https://sourceforge.net/p/glfw/discussion/247562/thread/ff457641/#73d3):

Sorry, I didn’t make myself clear. I managed to compile my dll with glfw.lib  
linked,. There is a CControl class defined in my dll. CControl is derived from  
abstract class IControl. IControl has a public pure virtual member function  
GetKey. GetKey is defined in CControl and just returns the result of a call to  
glfwGetKey function. In my exe I get a pointer ptr to IControl object (it’s  
static type is CControl) and I “wait” in a loop for escape key  
(ptr-\>GetKey…).

If glfw.lib is linked with my dll, pressing escape key has no effect (as if  
escape key released)  
If glfwdll.lib is linked with my dll, ptr-\>GetKey returns value indicating  
that escape key was pressed.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [March 18, 2012, 10:25pm UTC](https://discourse.glfw.org/t/glfwgetkey-call-from-user-dll-not-working/240/6 "2012-03-18T22:25:34Z")

</div>

**[elmindreda](https://sourceforge.net/u/elmindreda/)** wrote on [Sunday, March 18, 2012](https://sourceforge.net/p/glfw/discussion/247562/thread/ff457641/#2ae0):

Are you defining GLFW\_DLL when using glfw.lib?
