Unresolved external symbol with static library VS2017


#1

Hello,

I’m starting to learn GLFW to use in C, I come from SDL where I know a lot of it and wanted to start doing OpenGL, so I wanted to try GLFW to learn something different from SDL.

Everything is good expect if I want to link the static one I got unresolved external symbol while compiling.

I tried with the one downloaded on the main website and compiling it myself but nothing to do for glfw3.lib.
It only work only glfw3dll.lib

Anyone having this issue ?

I looked the function that are the problem and it look like it’s Windows’s one

Config : I use Visual Studio 2017, I only link glfw3.lib, and I use glad (compiling the .c/.h on the project)

Thank’s


#2

When building applications with the DLL you need to define GLFW_DLL, which won’t work with the static library. See http://www.glfw.org/docs/latest/build_guide.html

Does this help?


#3

When liking with glfw static library you need to link to extra windows libraries. For example, gdi32.lib. To find out to which libraries you need to link, search for unresolved symbol in MSDN. For example, “GetClipboardData” is here: https://msdn.microsoft.com/en-us/library/windows/desktop/ms649039.aspx At the bottom of page in table there is information about which library you need to use it, for this example it is “user32.lib”.


#4

@mmozeiko is correct, apologies for my rushed response.

If you create a new project in Visual Studio you should already have these libraries in your list of linker inputs.


#5

I Didn’t defined this but thank’s.

I think the problem is for the windows linking (because of the error log) but I didn’t found the lib needed. I’m gonna try this tonight.
I create empty project when doing a new project so they are probably not linked.

Thank’s


#6

So I added
User32.lib
Gdi32.lib
Shell32.lib
And now it work :slight_smile:

Thank’s, that’s strange no one had that before