编译错误:在 kubuntu linux 中找不到 -lGLU 和 -lGL

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8321628/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 02:38:20  来源:igfitidea点击:

Compiling error: cannot find -lGLU and -lGL in kubuntu linux

c++linuxqtopenglkubuntu

提问by G-71

I have some problems with compiling "hello world" application in kubuntu linux 11.10. This is project file:

我在 kubuntu linux 11.10 中编译“hello world”应用程序时遇到了一些问题。这是项目文件:

// opengltext.pro
SOURCES += \
    main.cpp
QT += opengl

And one cpp file:

和一个 cpp 文件:

    // main.cpp

    #include <QApplication>

    int main( int argc, char *argv[] )
    {
        QApplication app( argc, argv );
        return app.exec();
    }

i have got the following errors:

我有以下错误:

:-1: error: cannot find -lGLU
:-1: error: cannot find -lGL
:-1: error: collect2: ld returned 1 exit status

I try find in google the solution of this problem. But didn't find. i try to install:

我尝试在谷歌中找到这个问题的解决方案。但是没找到。我尝试安装:

sudo apt-get install libglw1-mesa-dev

but this error is still taking place

但这个错误仍在发生

What's the problem?

有什么问题?

采纳答案by favoretti

You need the following 2 packages:

您需要以下 2 个包:

xlibmesa-gl-dev
xlibmesa-glu-dev

-- edit --

- 编辑 -

Thanks for correction @ephemient, these were obsolete names, right names are:

感谢@ephemient 的更正,这些都是过时的名字,正确的名字是:

libgl1-mesa-dev
libglu1-mesa-dev

回答by LovesTha

In addition to the the answer about installing the right libraries (sudo apt-get install libgl1-mesa-dev libglu1-mesa-dev) you may need to add: unix:LIBS += -L/usr/lib/x86_64-linux-gnu/mesa/ to your .pro file, I know I needed to. Of course that path may be different if your using 32bit software or other system dependant reasons.

除了有关安装正确库的答案(sudo apt-get install libgl1-mesa-dev libglu1-mesa-dev)之外,您可能还需要添加:unix:LIBS += -L/usr/lib/x86_64-linux- gnu/mesa/ 到您的 .pro 文件,我知道我需要这样做。当然,如果您使用 32 位软件或其他系统相关的原因,该路径可能会有所不同。