Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Need help Setting up GLFW for VS2010


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 Prognatus   Members   -  Reputation: 198

Like
0Likes
Like

Posted 04 July 2013 - 07:55 PM

I get this error every time i debug this code. I downloaded the new version of glfw from www.glfw.org. I have linked both the library's  glfw3.lib and glfw3dll.lib to the linker  input and general.
 
#define GLFW_DLL
#include <GLFW/glfw3.h>


int main(void)
{
    GLFWwindow* window;

    /* Initialize the library */
    if (!glfwInit())
        return -1;

    /* Create a windowed mode window and its OpenGL context */
    window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
    if (!window)
    {
        glfwTerminate();
        return -1;
    }

    /* Make the window's context current */
    glfwMakeContextCurrent(window);

    /* Loop until the user closes the window */
    while (!glfwWindowShouldClose(window))
    {
        /* Render here */

        /* Swap front and back buffers */
        glfwSwapBuffers(window);

        /* Poll for and process events */
        glfwPollEvents();
    }

    glfwTerminate();
    return 0;
}




1>main.obj : error LNK2019: unresolved external symbol __imp__glfwPollEvents referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__glfwSwapBuffers referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__glfwWindowShouldClose referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__glfwMakeContextCurrent referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__glfwTerminate referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__glfwCreateWindow referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__glfwInit referenced in function _main
1>c:\users\william\documents\visual studio 2010\Projects\test 1\Debug\test 1.exe : fatal error LNK1120: 7 unresolved externals

Sponsor:

#2 BitMaster   Crossbones+   -  Reputation: 4227

Like
0Likes
Like

Posted 05 July 2013 - 12:39 AM

I have linked both the library's  glfw3.lib and glfw3dll.lib to the linker  input and general.


I'm not sure that is a good idea. I'm not familiar with the precompiled build for GLFW but from a quick glance I got the impression glfw3.lib is for statically linking GLFW while glfw3dll.lib is for dynamically linking it. Supplying both to the linker might have you end up with errors like that.
That said, I would in general advise to only link something as small and simple like GLFW dynamically if there is a specific need for that. So my advice would be to remove the define for GLFW_DLL and only link glfw3.lib.

#3 Prognatus   Members   -  Reputation: 198

Like
0Likes
Like

Posted 05 July 2013 - 12:58 PM

I have linked both the library's  glfw3.lib and glfw3dll.lib to the linker  input and general.


I'm not sure that is a good idea. I'm not familiar with the precompiled build for GLFW but from a quick glance I got the impression glfw3.lib is for statically linking GLFW while glfw3dll.lib is for dynamically linking it. Supplying both to the linker might have you end up with errors like that.
That said, I would in general advise to only link something as small and simple like GLFW dynamically if there is a specific need for that. So my advice would be to remove the define for GLFW_DLL and only link glfw3.lib.


I tried what you said but i still get the same error

#4 BitMaster   Crossbones+   -  Reputation: 4227

Like
0Likes
Like

Posted 08 July 2013 - 12:26 AM

Is it possible you are linking an x86 library into an x64 project or vice versa?

Edited by BitMaster, 08 July 2013 - 02:43 AM.


#5 MarkS   Prime Members   -  Reputation: 882

Like
0Likes
Like

Posted 08 July 2013 - 02:08 AM

[edit]

OK, I just tried to replicate your problem and was able to do so. Make absolutely sure that you have glfw3.lib OR glfw3dll.lib added to "project properties->Linker->Input->Additional Dependencies" for EVERY configuration. I think that you added the library for either your Release or Debug configuration, but not both. I've done this more than once. I found it helpful to get into the habit of changing the project configuration to "All Configurations" before setting directories and adding libraries. Saves a LOT of headaches!

Edited by MarkS, 08 July 2013 - 02:19 AM.


#6 Prognatus   Members   -  Reputation: 198

Like
1Likes
Like

Posted 09 July 2013 - 10:11 PM

I manged to fix it. What i did wrong was download the win64 version of glfw instead of the win32. But now i have a new problem every time i call Initglew() my program clashes.

//Sets the error callback in case of error
glfwSetErrorCallback(Error_callback);

//initailize glfw
if (!glfwInit())
{
exit(EXIT_FAILURE);
return false;
}
//create window
window = glfwCreateWindow(640, 480, "Simple example", NULL, NULL);

if (!window)
{
glfwTerminate();
exit(EXIT_FAILURE);
return false;
}


glewExperimental=true;
GLenum err=glewInit();
if(err!=GLEW_OK)
{
//Problem: glewInit failed, something is seriously wrong.
glfwTerminate();
exit(EXIT_FAILURE);
return false;
}
//set window context
glfwMakeContextCurrent(window);
//sets Key callback
glfwSetKeyCallback(window, Key_callback);

return true;

#7 BitMaster   Crossbones+   -  Reputation: 4227

Like
2Likes
Like

Posted 10 July 2013 - 02:25 AM

glfwMakeContextCurrent(window) needs to be called before you initialize GLEW.

#8 Prognatus   Members   -  Reputation: 198

Like
0Likes
Like

Posted 10 July 2013 - 11:54 AM

glfwMakeContextCurrent(window) needs to be called before you initialize GLEW.



Thx that solved my problem.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS