Link error on KeyEventFunction

sn1ckers wrote on Sunday, June 16, 2013:

I was running Horde3D and tried to run it with the latest glfw(3.0), and only include the dlls. And I got everything working except the KeyEvent where I got a link error.

Error 1 error LNK2019: unresolved external symbol “bool __cdecl setupWindow(int,int,bool)” (?setupWindow@@YA_NHH_N@Z) referenced in function “void __cdecl keyPressListener(struct GLFWwindow *,int,int,int,int)” (?keyPressListener@@YAXPAUGLFWwindow@@HHHH@Z) F:\utveckling\gameLabb\ChicagoStandalone - Copy\main.obj ChicagoStandalone

The Horde3D example im running is Chicago. And if I remove the KeyEvent everything else works with mouse input and rendering. Any idea what might would be wrong?

I also tried to compile glfw to dlls but I cant figured it out, so I downloaded the glfw-3.0.bin.WIN32 and used the dlls and lib from that package. I also tried other version of the glfw.win32 packages but then a got alot more link errors.

elmindreda wrote on Sunday, June 16, 2013:

There are no functions with those names in GLFW. It’s an issue in Horde3D.

sn1ckers wrote on Sunday, June 16, 2013:

Sorry I should have provided more info. But it is from glfw I encounter the problem.

This is what i set up, and it is from the glfw3.h:

/*! @brief The function signature for keyboard key callbacks.
 *
 *  This is the function signature for keyboard key callback functions.
 *
 *  @param[in] window The window that received the event.
 *  @param[in] key The [keyboard key](@ref keys) that was pressed or released.
 *  @param[in] scancode The system-specific scancode of the key.
 *  @param[in] action @ref GLFW_PRESS, @ref GLFW_RELEASE or @ref GLFW_REPEAT.
 *  @param[in] mods Bit field describing which [modifier keys](@ref mods) were
 *  held down.
 *
 *  @sa glfwSetKeyCallback
 *
 *  @ingroup input
 */
typedef void (* GLFWkeyfun)(GLFWwindow*,int,int,int,int);

and this is how i set it up:

glfwSetKeyCallback( window, keyPressListener );

static void keyPressListener(GLFWwindow* window, int key, int scancode, int action, int mods )

I got glfwSetCursorPosCallback( window, mouseMoveListener ); and glfwSetWindowCloseCallback( window, windowCloseListener ); to work with the same approach but not for glfwSetKeyCallback :frowning:

elmindreda wrote on Sunday, June 16, 2013:

The eror message says that you’re calling setupWindow but that the linker cannot find it.

sn1ckers wrote on Sunday, June 16, 2013:

Thanks you very much :slight_smile: It was my own method that was wrong. So now I got it running. Im quite new to C++ so I don’t understand the link errors so well.

By the way do you know if there is a guide how to build dynamic libraries from C in visual studio? I searched but didn’t find any good straight on guide for a newbie as my self.

Thanks again.

elmindreda wrote on Sunday, June 16, 2013:

There probably is one on MSDN.