I apologize if this is a duplicate question, but I cannot find answers to this anywhere.
I am new to C++ and wish to start learning OpenGL. In order to do this, I need to setup both GLEW and GLFW. Despite reading documentation and doing a lot of research, I cannot figure out how to utilize C++ libraries statically and dynamically. The main reason I cannot find answers to this is due to the fact I am running on Ubuntu, whereas most resources are for doing so with Windows.
I have attempted to build the libraries with CMake, following documentation. I appear to successfully build the libraries, but the issue then comes when using these libraries with the compiler, which again I cannot find good enough answers to.
I have tried the following steps to installing GLEW and GLFW:
- Install GLEW from here.
- Install GLFW from here.
- Unzip GLEW & GLFW
- Go into the GLEW folder
- Run
make
,sudo make install
andmake clean
(following this) - Go into the GLFW folder
- Run
mkdir build
,cd build
andcmake ..
(following this)
This is where it gets tricky. - Run
mkdir test-project
,mkdir test-project/dependencies
,mkdir test-project/dependencies/include
, mkdirtest-project/dependencies/lib
- Move
GLFW
folder in the GLFW include directory to the project includes directory
I didn't know what I was supposed to link, so I skipped this part. - Move
GL
folder in the GLEW include directory to the project includes directory - Move the contents of the
lib
folder to the projectlib
directory - Create a
main.cpp
file in the project folder - Add this to
main.cpp
:
#include <GL/glew.h>
#include <GLFW/glfw3.h>
int main()
{
return 0;
}
- Go to the project folder and execute
g++ ./main.cpp -I ./dependencies/include -L ./dependencies/lib
I then receive this error:
In file included from ./main.cpp:1:
./dependencies/include/GL/glew.h:1205:14: fatal error: GL/glu.h: No such file or directory
1205 | # include <GL/glu.h>
| ^~~~~~~~~~
compilation terminated.
Please could somebody explain how C++ libraries work dynamically and statically, how you would install a library dynamically and statically, and provide some steps to using GLEW and GLFW on Ubuntu.
Any help would be greatly appreciated!