Why Does My OpenGL Code Show a Linker Error in Dev C++?

  • Context: C/C++ 
  • Thread starter Thread starter Mr Virtual
  • Start date Start date
  • Tags Tags
    Compiler Error
Click For Summary
SUMMARY

The linker error encountered in Dev C++ version 4.9.9.2 when compiling OpenGL code is due to a missing reference to the GLU library. Specifically, the error message "undefined reference to `gluPerspective@32'" indicates that the linker cannot find the glu32 library. To resolve this issue, users must include the linker flags -lopengl32, -lglaux32, and -lglu32 in the project settings. Following these steps ensures successful compilation and execution of OpenGL programs.

PREREQUISITES
  • Familiarity with OpenGL programming concepts
  • Understanding of linker errors in C++ development
  • Experience using Dev C++ version 4.9.9.2
  • Knowledge of project settings and configuration in IDEs
NEXT STEPS
  • Research how to configure linker settings in Dev C++
  • Learn about OpenGL library dependencies and their usage
  • Explore the NeHe tutorials for advanced OpenGL techniques
  • Investigate common linker errors and their resolutions in C++
USEFUL FOR

This discussion is beneficial for OpenGL developers, C++ programmers using Dev C++, and anyone troubleshooting linker errors in their graphics programming projects.

Mr Virtual
Messages
218
Reaction score
4
I am using Dev C++ compiler version 4.9.9.2
When I compiled my OpenGL code, the compiler gave the following error:

[Linker error] undefined reference to `gluPerspective@32'
ld returned 1 exit status
[Build Error] [Project1.exe] Error 1

I am taking NeHe tutorials, where a function gluPerspective() has been used. When I compiled the same code sometime back, it worked perfectly. Any idea what this error is and how to tackle it?

regards
Mr V
 
Technology news on Phys.org
Try copying and pasting the code into a new workspace. That sometimes fixes linker errors.
 
I tried this but nothing happened. Never mind because I found out what was causing the error: the linker section of the project had a file called -lglu32 missing. On includeing this file, the program ran perfectly.

For anybody who faces a similar problem in OpenGL and is using Dev C++:
1. Go to 'Project' and click on 'Project Options'.
2. In the dialog box that opens, click on 'Parameters'. You will see the dialog box divided into three parts: Compiler, C++ Compiler, Linker. Your job is to check that the linker category contains all the three files: -lopengl32 -lglaux32 -lglu32, written in any order. Click OK, and try to recompile and run the program. It should work fine now.

regards
Mr V
 

Similar threads

  • · Replies 22 ·
Replies
22
Views
4K
  • · Replies 39 ·
2
Replies
39
Views
5K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 16 ·
Replies
16
Views
9K
  • · Replies 1 ·
Replies
1
Views
10K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 3 ·
Replies
3
Views
6K
  • · Replies 2 ·
Replies
2
Views
2K