0

I am trying to compile following code:

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

#include <glm/glm.hpp>
using namespace glm;

int main(int argc, char **argv) {
    if (glewInit() != GLEW_OK) {
    std::cout << "test" << std::endl;
    }
  return 0;
}

with following command: g++ main.cpp -lglfw -lGL -lm -lX11 -lpthread -lXrandr -ldl. It gives this result:

/usr/bin/ld: /tmp/cclA7BQ0.o: in function `main':
main.cpp:(.text+0x14): undefined reference to `glewInit'
collect2: error: ld returned 1 exit status

I have also tried linking -lglfw3 instead of -lglfw but it doesn't work either. I use ubuntu 22.04.

Rabbid76
  • 202,892
  • 27
  • 131
  • 174

0 Answers0