I'm trying to make a very simple game using OpenGL & GLFW. I have gotten my current code to compile with no problem on Ubuntu, but when I try it on Windows I get all sorts of unresolved external errors.
I have included in both my main.cpp
and my game.h
files:
#include<GLFW/glfw3.h>
I've tried using:
#define GLFW_DLL
#include<GLFW/glfw3.h>
and then linking glfwdll.lib
instead of glfw3.lib
, and that solved some of the errors, but not all of them. Either way, I'm using the static library on Ubuntu so I want to use it on Windows also.
After researching it, I've tried including User32.lib
and kernel32.lib
,removing the default libraries (using Zl), and a bunch of other things that I can't remember (but they didn't work).
My current compile command looks like this:
@echo off
cl /Zl /MT game.cpp /I C:\dev\include /link "C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x64\User32.lib" "C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x64\kernel32.lib" C:\dev\lib\glfw3.lib C:\dev\lib\OpenGL32.lib
cl /Zl main.cpp /I C:\dev\include /link C:\dev\lib\glfw3.lib C:\Users\Daniel\projects\game\game.obj C:\dev\lib\OpenGL32.lib "C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x64\User32.lib" "C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x64\kernel32.lib"
With this, the object file compiles with no problem, but with the main file I keep getting unresolved external errors for all of the glfw and openGl funcions (whether I used them or not) in my object file and they are from the object file and the glfw.lib file.
What's really confusing to me about this is that the my game class object file compiles without any issues, but then it has errors when I link it.
Does anyone know how to compile this?
I've been looking into this for awhile now, and I found someone who said that it works if you use the 32bit binaries. I had been using the 64bit binaries when I had this problem. I downloaded the 32bit binaries and tried it with the same methods, and it compiled no problem.
I have no idea why this is, but for anyone who's having my problem, the 32bit binaries worked.