0

When I try to compile it, I get a strange error:

[domon@archlinux TileVox-engine]$ g++ -c engine_main.cpp
[domon@archlinux TileVox-engine]$ g++ engine_main.o -o game -L -lGL -lglfw -lGLEW -lglut -lGLU
/usr/bin/ld: engine_main.o: undefined reference to symbol 'glViewport'
/usr/bin/ld: /usr/lib/libGL.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

Code:

#include <iostream>
#define GLEW_STATIC
#include <GL/glew.h>
#include <GLFW/glfw3.h>

using namespace std;

int window_width = 1280;
int window_height = 720;

int main()
{
    glfwInit();
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);

    GLFWwindow* window = glfwCreateWindow(window_width, window_height, "TileVox-engine: Main scene", nullptr, nullptr);
    if (window == nullptr){
        cout << "TileVox-engine Error: failed to create OpenGL profile";
        glfwTerminate();

        return -1;
    }

    glfwMakeContextCurrent(window);

    glewExperimental = GL_TRUE;

    if (glewInit() != GLEW_OK){
        cout << "OpenGL Error: starting failed";
    }

    glViewport(0,0, window_width, window_height);

    while (!glfwWindowShouldClose(window))
    {
        glfwPollEvents();
        glfwSwapBuffers(window);
    }
    glfwTerminate();
    return 0;
}

But there are no errors here, and I compiled and added the libraries correctly, what could be the problem?

genpfault
  • 51,148
  • 11
  • 85
  • 139
domon41c
  • 11
  • 5

0 Answers0