glfwGetKey call from user dll not working

mrdarkal wrote on Friday, March 16, 2012:

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?

elmindreda wrote on Friday, March 16, 2012:

Did you define GLFW_DLL?

mrdarkal wrote on Sunday, March 18, 2012:

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?

elmindreda wrote on Sunday, March 18, 2012:

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

mrdarkal wrote on Sunday, March 18, 2012:

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.

elmindreda wrote on Sunday, March 18, 2012:

Are you defining GLFW_DLL when using glfw.lib?