OpenGL: compiler showing error

In summary, the conversation discusses an error that occurred while compiling OpenGL code using the Dev C++ compiler version 4.9.9.2. The error was caused by a missing file called -lglu32 in the linker section of the project. The solution was to add this file to the linker category in the project options and then recompile the code. This resolved the issue and the program ran successfully. The conversation also provides step-by-step instructions for anyone facing a similar problem in OpenGL and using Dev C++.
  • #1
Mr Virtual
218
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
  • #2
Try copying and pasting the code into a new workspace. That sometimes fixes linker errors.
 
  • #3
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
 

1. Why am I getting an error when trying to compile my OpenGL code?

There could be several reasons why your compiler is showing an error when trying to compile your OpenGL code. Some common causes include syntax errors, missing libraries, or incorrect compiler settings. It's important to carefully check your code for any mistakes and make sure all necessary libraries are included and properly linked.

2. How do I fix a "missing library" error when compiling my OpenGL code?

If your compiler is showing an error indicating a missing library, you may need to install the necessary library or add it to your project's dependencies. Make sure you are using the correct version of the library and that it is properly linked in your project settings.

3. What are some common syntax errors in OpenGL code?

Some common syntax errors in OpenGL code include missing semicolons, incorrect function names or parameters, and incorrect use of OpenGL keywords. It's important to carefully follow the correct syntax for each function and to double check for any typos or mistakes.

4. How can I troubleshoot compiler errors in my OpenGL code?

One way to troubleshoot compiler errors in your OpenGL code is to use a debugger. This can help pinpoint the exact location of the error and provide more information about the cause. Additionally, checking online forums and documentation for the specific OpenGL function or library you are using can also provide helpful insights.

5. Can I use any compiler to compile my OpenGL code?

While some compilers may have built-in support for OpenGL, it is generally recommended to use a compiler that is specifically designed for graphics programming. Some popular options include Visual Studio, Code::Blocks, and Eclipse. Make sure to also check the compiler's documentation for any specific settings or configurations needed for OpenGL.

Similar threads

Replies
6
Views
1K
  • Programming and Computer Science
Replies
22
Views
2K
  • Nuclear Engineering
Replies
6
Views
1K
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
5
Views
9K
  • Programming and Computer Science
Replies
3
Views
4K
  • Programming and Computer Science
Replies
16
Views
8K
Replies
16
Views
2K
  • Programming and Computer Science
Replies
4
Views
3K
Back
Top