Solution to failure to use the GLU library in Ubuntu QtOpenGL

Source: Internet
Author: User
The QtOpenGL program written and compiled in Windows is compiled in Ubuntu. If you use Qt of version 4.6 provided in the Ubuntu Software Center for compilation, there is no problem at all, however, when using the QtSDK version 4.7 from the Nokia official website, it always prompts that the relevant interfaces in the glu library do not exist, but I have installed the GL, GLU, and other libraries. I have met this problem on several machines and have obtained the following solutions through experiments: 1. The interface for modifying a library in the makefile file is not recognized.

The QtOpenGL program written and compiled in Windows is compiled in Ubuntu. If you use Qt of version 4.6 provided in the Ubuntu Software Center for compilation, there is no problem at all, however, when using the QtSDK version 4.7 from the Nokia official website, it always prompts that the relevant interfaces in the glu library do not exist, but I have installed the GL, GLU, and other libraries. I have met this problem on several machines and have obtained the following solutions through experiments:

1. Modify the makefile file

The most likely reason a library's interface is not recognized is that it does not contain the header file of the library. You can try

# Include

Before adding the CPP file that uses the GLU database, the result shows that the GLU database still cannot be used, and then the qmake file is used according *. the LIBS of makefile generated by pro only contains the GL Library but does not contain the GLU library. This is the crux of the problem, therefore, you can simply add LIBS in makefile to-lGLU to solve this problem, and then the compilation will be complete.

The premise of this method is that # include , # Include Add to Qt/qgl. h to avoid repeated addition.

2. In the *. pro file, specify the use of the GLU library.

Since Qt makefile is generated based on *. pro, you can automatically generate the makefile linked to the GLU library by adding a link to *. pro. *. Pro uses LIBS to mark the library to be linked to the project. You can add it to *. pro.

LIBS + =-lGLU

To specify the link to the database. Of course, the premise for implementing www.linuxidc.com is that # include , # Include Add to Qt/qgl. h to avoid repeated addition.

3. Correctly install the relevant OpenGL library

Since Qt 4.6 provided in the Ubuntu software center does not need to be so troublesome to modify related files, and on my old laptop, at that time, a lot of GL-related libraries were installed in a confused manner, and the above two steps were not required. It can be seen that the main problem is the installation and configuration of the GLU library. correct installation and configuration of the relevant OpenGL library and Qt are the fundamental solutions.

However, I am not very clear about how to configure it, and Qt is no longer the current primary learning task, so I will not go into it. I will wait for some time to study this issue and further improve this article. Therefore, I will omit a few words here...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.