Reputation: 25
I modified my makefile for Win64, but I get "undefined reference" errors when compiling, which is strange since this doesn't happen on the Win32 makefile. The OpenGL libraries are all included, and I modified the library directory to point to the Win64 DLLs.
GLEW works fine, despite the millions of warnings.
The makefile:
# Test Game Windows 64-bit Makefile
# Copyright (C) 2020 MarioMario456
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
binaries/win64/testgame : source/main.cpp
i686-w64-mingw32-g++ source/main.cpp source/glew.c -Isource -Llibrary/win64 -lopengl32 -lglu32 -lglfw3 -lgdi32 -o binaries/win64/testgame
The main source file:
/* Test Game Main Source File
* Copyright (C) 2020 MarioMario456
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version. */
#include <iostream>
#include <GLFW/glfw3.h>
#include "main.hpp"
using namespace std;
int main() {
// Game initialization
if (!glfwInit()) {
cout << "An error occurred while initializing the game. Please try again.";
return -1;
}
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
GLFWwindow* window = glfwCreateWindow(640, 480, "3D Shooter", NULL, NULL);
glfwMakeContextCurrent(window);
GLFWmonitor* monitor = glfwGetPrimaryMonitor();
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
int monitorWidth = mode->width;
int monitorHeight = mode->height;
int windowWidth, windowHeight;
glfwGetWindowSize(window, &windowWidth, &windowHeight);
glfwSetWindowPos(window, (monitorWidth-windowWidth)/2, (monitorHeight-windowHeight)/2);
while (!glfwWindowShouldClose(window)) {
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
glfwPollEvents();
}
}
The errors:
C:\Users\(REDACTED)\AppData\Local\Temp\cc7Qjwm6.o:main.cpp:(.text+0x17): undefined reference to `glfwInit'
C:\Users\(REDACTED)\AppData\Local\Temp\cc7Qjwm6.o:main.cpp:(.text+0x52): undefined reference to `glfwWindowHint'
C:\Users\(REDACTED)\AppData\Local\Temp\cc7Qjwm6.o:main.cpp:(.text+0x7e): undefined reference to `glfwCreateWindow'
C:\Users\(REDACTED)\AppData\Local\Temp\cc7Qjwm6.o:main.cpp:(.text+0x8c): undefined reference to `glfwMakeContextCurrent'
C:\Users\(REDACTED)\AppData\Local\Temp\cc7Qjwm6.o:main.cpp:(.text+0x91): undefined reference to `glfwGetPrimaryMonitor'
C:\Users\(REDACTED)\AppData\Local\Temp\cc7Qjwm6.o:main.cpp:(.text+0x9f): undefined reference to `glfwGetVideoMode'
C:\Users\(REDACTED)\AppData\Local\Temp\cc7Qjwm6.o:main.cpp:(.text+0xcc): undefined reference to `glfwGetWindowSize'
C:\Users\(REDACTED)\AppData\Local\Temp\cc7Qjwm6.o:main.cpp:(.text+0x107): undefined reference to `glfwSetWindowPos'
C:\Users\(REDACTED)\AppData\Local\Temp\cc7Qjwm6.o:main.cpp:(.text+0x112): undefined reference to `glfwWindowShouldClose'
C:\Users\(REDACTED)\AppData\Local\Temp\cc7Qjwm6.o:main.cpp:(.text+0x137): undefined reference to `glfwSwapBuffers'
C:\Users\(REDACTED)\AppData\Local\Temp\cc7Qjwm6.o:main.cpp:(.text+0x13c): undefined reference to `glfwPollEvents'
Upvotes: 1
Views: 375
Reputation: 25
I managed to fix it by switching to 64-bit Windows, installing the 64-bit version of MinGW-w64, and modifying the makefile to use "x86_64-w64-mingw32-g++" instead of "i686-w64-mingw32-g++".
Upvotes: 1