I have three files, there called glfw3.h glfw3native.h and main.cpp.
File structure:
Game:
Dependencies:
include:
glfw3.h
glfw3native.h
src:
main.cpp
The first two have thousands of lines of code in so I wont post them. main.cp#include <GLFW/glfw3.h> main.cpp has this in it:
#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 */
glClear(GL_COLOR_BUFFER_BIT);
/* Swap front and back buffers */
glfwSwapBuffers(window);
/* Poll for and process events */
glfwPollEvents();
}
glfwTerminate();
return 0;
}
When I try to build main.cpp I get this:
/usr/bin/ld: /tmp/ccLgWsQA.o: in function `main':
main.cpp:(.text+0xd): undefined reference to `glfwInit'
/usr/bin/ld: main.cpp:(.text+0x44): undefined reference to `glfwCreateWindow'
/usr/bin/ld: main.cpp:(.text+0x54): undefined reference to `glfwTerminate'
/usr/bin/ld: main.cpp:(.text+0x67): undefined reference to `glfwMakeContextCurrent'
/usr/bin/ld: main.cpp:(.text+0x73): undefined reference to `glClear'
/usr/bin/ld: main.cpp:(.text+0x7f): undefined reference to `glfwSwapBuffers'
/usr/bin/ld: main.cpp:(.text+0x84): undefined reference to `glfwPollEvents'
/usr/bin/ld: main.cpp:(.text+0x90): undefined reference to `glfwWindowShouldClose'
/usr/bin/ld: main.cpp:(.text+0x9e): undefined reference to `glfwTerminate'
collect2: error: ld returned 1 exit status
I dont know how to reference them in main.cpp.