Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nbody compilation error, GL/gl.h not found. #298

Open
ar-valdez opened this issue Sep 20, 2024 · 3 comments
Open

nbody compilation error, GL/gl.h not found. #298

ar-valdez opened this issue Sep 20, 2024 · 3 comments
Labels
question Further information is requested

Comments

@ar-valdez
Copy link

Hello, I followed the guidance of this historical issue but it still fails to compile.
Let me post my compilation error here:

(base) abv5357@E1-055656:~/Documents/FutureProjects/cuda-samples/Samples/5_Domain_Specific/nbody$ make dbg=1
WARNING - GCC variable has been deprecated
WARNING - please use HOST_COMPILER=/home/abv5357/anaconda3/bin/x86_64-conda-linux-gnu-gcc instead
/usr/local/cuda/bin/nvcc -ccbin /home/abv5357/anaconda3/bin/x86_64-conda-linux-gnu-gcc -I../../../Common  -m64 -g -G    -ftz=true --threads 0 --std=c++11 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80 -gencode arch=compute_86,code=sm_86 -gencode arch=compute_89,code=sm_89 -gencode arch=compute_90,code=sm_90 -gencode arch=compute_90,code=compute_90 -o bodysystemcuda.o -c bodysystemcuda.cu
In file included from ../../../Common/GL/freeglut.h:17,
                 from bodysystemcuda.cu:35:
../../../Common/GL/freeglut_std.h:84:10: fatal error: GL/gl.h: No such file or directory
   84 | #include <GL/gl.h>
      |          ^~~~~~~~~
compilation terminated

I am sure that mesa-common-dev is installed in my system. You can check it with the next attempt to re-install.

(base) abv5357@E1-055656:~$ sudo apt install mesa-common-dev
[sudo] password for abv5357: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
mesa-common-dev is already the newest version (21.2.6-0ubuntu0.1~20.04.2).
0 upgraded, 0 newly installed, 0 to remove and 65 not upgraded.

Have I missed something? In case you need my system detail here they are:

(base) abv5357@E1-055656:~$ nvidia-smi
Fri Sep 20 08:53:26 2024

+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 560.35.03              Driver Version: 560.35.03      CUDA Version: 12.6     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA TITAN Xp                Off |   00000000:C1:00.0  On |                  N/A |
| 23%   35C    P8             19W /  250W |     448MiB /  12288MiB |     26%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
                                                                                         
+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|    0   N/A  N/A      1970      G   /usr/lib/xorg/Xorg                             35MiB |
|    0   N/A  N/A      3467      G   /usr/lib/xorg/Xorg                            183MiB |
|    0   N/A  N/A      3628      G   /usr/bin/gnome-shell                          114MiB |
|    0   N/A  N/A      8637      G   ...seed-version=20240918-180211.633000         98MiB |
+-----------------------------------------------------------------------------------------+

Thank you.-

@soumikiith
Copy link

Hi,
As I was referring to the historical issue, I found it almost correct.
However, I am referring to the approximate solution here; please let me know if it works for you.

This error indicates that the OpenGL header file GL/gl.h is missing or not found in the expected location.
Hence, you should install the missing packages first:

For Ubuntu/Debian-based systems:

sudo apt-get install mesa-common-dev libgl1-mesa-dev

For Fedora/Red Hat-based systems:

sudo dnf install mesa-libGL-devel

you may need to add the include directory to your compiler flags:

nvcc -I /usr/include/GL your_file.c -lGL -lglut

This actually worked for me!!

@ar-valdez
Copy link
Author

Thanks @soumikiith. In my case, I "solve" the problem of deactivating the base environment... No idea why this happened, but it works... I'll try yours and check the output...

@rwarmstr
Copy link
Collaborator

As a quick note with the update to CMake this should hopefully work better in the 12.8 release and newer - please let us know how it goes.

@rwarmstr rwarmstr added the question Further information is requested label Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants