Я подключил библиотеки, но линковщик всё равно не пропускает.
Структура проекта:
Консоль:
g++ -LC:\Users\79306\Documents\GitHub\2DPrimitiveLib\source\deps\lib -IC:\Users\79306\Documents\GitHub\2DPrimitiveLib\source\deps\include -Wl,--start-group -lglfw3 -lopengl32 -lglad -Wl,--end-group Window.cpp main.cpp -o exe.exe
c:/users/79306/desktop/development-libraries/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\79306\AppData\Local\Temp\ccUvV73h.o:Window.cpp:(.text+0x2e): undefined reference to `glfwInit'
c:/users/79306/desktop/development-libraries/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\79306\AppData\Local\Temp\ccUvV73h.o:Window.cpp:(.text+0x3d): undefined reference to `glfwWindowHint'
c:/users/79306/desktop/development-libraries/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\79306\AppData\Local\Temp\ccUvV73h.o:Window.cpp:(.text+0x4c): undefined reference to `glfwWindowHint'
c:/users/79306/desktop/development-libraries/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\79306\AppData\Local\Temp\ccUvV73h.o:Window.cpp:(.text+0x5b): undefined reference to `glfwWindowHint'
c:/users/79306/desktop/development-libraries/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\79306\AppData\Local\Temp\ccUvV73h.o:Window.cpp:(.text+0x8d): undefined reference to `glfwCreateWindow'
c:/users/79306/desktop/development-libraries/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\79306\AppData\Local\Temp\ccUvV73h.o:Window.cpp:(.text+0x153): undefined reference to `glfwDestroyWindow'
c:/users/79306/desktop/development-libraries/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\79306\AppData\Local\Temp\ccUvV73h.o:Window.cpp:(.text+0x163): undefined reference to `glfwTerminate'
c:/users/79306/desktop/development-libraries/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\79306\AppData\Local\Temp\ccUvV73h.o:Window.cpp:(.rdata$.refptr.glad_glViewport[.refptr.glad_glViewport]+0x0): undefined reference to `glad_glViewport'
collect2.exe: error: ld returned 1 exit status
main.cpp
#include "Window.hpp"
int main()
{
Window win(233, 322);
return 0;
}
Window.hpp
#ifndef Window_DEF
#define Window_DEF
#include "deps/include/glad/glad.h"
#include "deps/include/GLFW/glfw3.h"
#include "Point.hpp"
#include <iostream>
class Window
{
private:
GLFWwindow *window;
Point currentPoint;
public:
static int IsInitGLFW;
Window(int n, int m);
Point current() const
{
return currentPoint;
}
Point current(const Point &p);
~Window();
};
#endif
Window.cpp
#include "Window.hpp"
int Window::IsInitGLFW = 0;
Window::Window(int n, int m)
{
if (IsInitGLFW == 0)
{
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
IsInitGLFW++;
}
window = glfwCreateWindow(n, m, "Window", NULL, NULL);
// Setting rendering viewport
glViewport(0, 0, n, m);
if (window == NULL)
{
std::cout << "Failed to create GLFW window" << std::endl;
}
};
Point Window::current(const Point &p)
{
currentPoint = p;
return currentPoint;
}
Window::~Window()
{
glfwDestroyWindow(window);
if (IsInitGLFW == 1)
{
glfwTerminate();
IsInitGLFW--;
}
}
g++ -LC:\Users\79306\Documents\GitHub\2DPrimitiveLib\source\deps\lib -IC:\Users\79306\Documents\GitHub\2DPrimitiveLib\source\deps\include -Wl,--start-group -lglfw3 -lopengl32 -lglad -Wl,--end-group Window.cpp main.cpp -o exe.exe - использую такую команду.