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

  • Thread starter Thread starter Mr Virtual
  • Start date Start date
  • Tags Tags
    Compiler Error
AI Thread Summary
The discussion centers around a linker error encountered while compiling OpenGL code using Dev C++ version 4.9.9.2, specifically the "undefined reference to `gluPerspective@32'" error. The user initially attempted to resolve the issue by copying the code into a new workspace, but this did not work. The solution was found by identifying that the linker was missing the necessary file "-lglu32." To fix similar issues, it is recommended to check the linker settings in the project options and ensure that the required libraries, specifically -lopengl32, -lglaux32, and -lglu32, are included. After adding these files, the program compiled and ran successfully.
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
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...

Similar threads

Replies
22
Views
3K
Replies
39
Views
4K
Replies
1
Views
9K
Replies
4
Views
4K
Replies
3
Views
5K
Replies
2
Views
2K
Back
Top