I have been trying to code with OpenGL without using a IDE, but the manual linking is really confusing me. I have a folder with the libglfw3.a, glfw3.h and a .cpp file with this example code.
#include "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 */
glClear(GL_COLOR_BUFFER_BIT);
/* Swap front and back buffers */
glfwSwapBuffers(window);
/* Poll for and process events */
glfwPollEvents();
}
glfwTerminate();
return 0;
}
I compile it like this.
g++ source.cpp -lglfw3 -o program
Yet I get these errors.
C:\Users\murra\Coding\Manual>g++ source.cpp -lglfw3 -o proc
C:\Users\murra\AppData\Local\Temp\ccO7xs1Q.o:source.cpp:(.text+0x17): undefined reference to `glfwInit'
C:\Users\murra\AppData\Local\Temp\ccO7xs1Q.o:source.cpp:(.text+0x56): undefined reference to `glfwCreateWindow'
C:\Users\murra\AppData\Local\Temp\ccO7xs1Q.o:source.cpp:(.text+0x64): undefined reference to `glfwTerminate'
C:\Users\murra\AppData\Local\Temp\ccO7xs1Q.o:source.cpp:(.text+0x76): undefined reference to `glfwMakeContextCurrent'
C:\Users\murra\AppData\Local\Temp\ccO7xs1Q.o:source.cpp:(.text+0x81): undefined reference to `glfwWindowShouldClose'
C:\Users\murra\AppData\Local\Temp\ccO7xs1Q.o:source.cpp:(.text+0x96): undefined reference to `_imp__glClear@4'
C:\Users\murra\AppData\Local\Temp\ccO7xs1Q.o:source.cpp:(.text+0xa6): undefined reference to `glfwSwapBuffers'
C:\Users\murra\AppData\Local\Temp\ccO7xs1Q.o:source.cpp:(.text+0xab): undefined reference to `glfwPollEvents'
C:\Users\murra\AppData\Local\Temp\ccO7xs1Q.o:source.cpp:(.text+0xb2): undefined reference to `glfwTerminate'
collect2.exe: error: ld returned 1 exit status
I'm quite new to this stuff so help would be appreciated.