Install_qt5_on_ubuntu

本文提供了在Ubuntu上安装Qt 5.7.0的详细步骤,包括下载安装包、配置编译器、安装必要的库文件等。此外还解决了OpenGL库缺失的问题,并提供了设置文件关联的方法。

以下内容转载自   http://wiki.qt.io/Install_Qt_5_on_Ubuntu

Install Qt 5 on Ubuntu

Introduction

This is a tutorial for installation of Qt 5.7.0 to Ubuntu 12.10. It may be used also for newer versions of Qt and Ubuntu. A difference for OpenGL has been found and added as a note below.

Installation Guide

  • Download

Visit Qt downloads page an  download a 32-bit or 64-bit Linux installationdepending your version of Ubuntu. The installation file can be also downloaded through the command line using wget.

Example:

wget http://download.qt.io/official_releases/qt/5.7/5.7.0/qt-opensource-linux-x64-5.7.0.run
  • Install

Adjust permission, run the installer and follow the instruction to complete the installation.

chmod +x qt-opensource-linux-x64-5.7.0.run
./qt-opensource-linux-x64-5.7.0.run
  • Install g++

Open a terminal and execute the following command to install g++:

sudo apt-get install build-essential
  • Install generic font configuration library - runtime

Open a terminal and execute the following command to install the full runtime files for the generic font configuration library:

sudo apt-get install libfontconfig1

Configure a compiler

Launch Qt Creator. Go to Tools > Options. Click Build & Run and select tab Kit. Configure a compiler if it is not automatically detected.

  • Install OpenGL libraries

Execute the following command to install OpenGL libraries:

sudo apt-get install mesa-common-dev

Note: Just installing the above-mentioned mesa-common-dev kit is not sufficient for more recent Ubuntu versions. Based on a comment in the Qt forum[1] an additional package needs installation. Execute following command:

sudo apt-get install libglu1-mesa-dev -y

Tested with Qt5.3.1 and Ubuntu 14.04 and it solved the problem with missing -lGL.

  • Set file association with pro files

When installing from the on-line source the file association is not done automatically. It also not show up when you try to associate it with file explorer. Create a file named “Qt-Creator.desktop” and fill the file with the following.

[Desktop Entry]
Version=1.0
Encoding=UTF-8
Type=Application
Name=QtCreator
Comment=QtCreator
NoDsiplay=true
Exec=(Install folder of QT)/Tools/QtCreator/bin/qtcreator %f
Icon=(Install folder of QT)/5.4/Src/qtdoc/doc/images/landing/icon_QtCreator_78x78px.png
Name[en_US]=Qt-Creator

Place this file in home .local/share/applications .

Edit a file named “defaults.list” in the same directory . Add the following line.

text/qtcreator=Qt-Creator.desktop;

open file mimeapps.list and check if the following line is present.

application/vnd.nokia.qt.qmakeprofile=qtcreator.desktop

if not add it under [added Associations].

Run the following command.

sudo update-mime-database /usr/share/mime

now Qt has been added to the list of file associations.

Troubleshooting

  • Qt Creator needs a compiler set up to build

Follow the instruction from the previous section to configure compiler for Qt Creator.

  • error: g++: Command not found

Solution:

sudo apt-get install build-essential
  • error: GL/gl.h: No such file or directory

Solution:

sudo apt-get install mesa-common-dev

References

  1. Jump up Qt 5.5.0 problem running examples [SOLVED]. 2015-09-22. Archived from the original on 2016-08-01. Retrieved 2016-08-01.
    Execute the following command to install OpenGL libraries: sudo apt-get install mesa-common-dev Note: Just installing the above-mentioned mesa-common-dev kit is not sufficient for more recent Ubuntu versions. Based on this comment in the forum an additional package needs installation. Execute following command: sudo apt-get install libglu1-mesa-dev -y Tested with Qt5.3.1 and Ubuntu 14.04 and it solved the problem with missing -lGL.
<think>好的,我现在需要帮助用户解决DCGAL_Qt5_DIR的配置问题。首先,用户提到了DCGAL,应该是CGAL,即计算几何算法库,可能拼写错误。用户之前的问题涉及到VTK和Qt5的配置,现在转向了CGAL的Qt5路径问题。我需要回忆一下CGAL的安装和配置过程,特别是与Qt5相关的部分。 首先,DCGAL_Qt5_DIR这个变量可能是指CGAL_Qt5_DIR,因为在CMake中,CGAL通常会使用CGAL_DIR或CGAL_Qt5_DIR这样的变量来指定路径。用户可能在配置CGAL时遇到找不到Qt5组件的问题,类似于之前VTK的问题。 接下来,我需要考虑常见的原因和解决方法。通常,这种路径错误是因为CMake无法自动找到Qt5的安装位置,尤其是当Qt5不是通过系统包管理器安装,或者安装路径不在默认搜索路径中时。用户可能需要手动设置CGAL_Qt5_DIR变量,指向Qt5的CMake模块所在目录。 根据之前的引用,用户之前处理过VTK的Qt5路径问题,解决方案包括在CMakeLists.txt中添加set命令或者安装特定包。但CGAL的情况可能略有不同,可能需要类似的方法,但具体路径可能不同。 首先,用户需要确认Qt5的安装位置。通常,Qt5的CMake文件位于Qt安装目录下的lib/cmake子目录中。例如,在Windows下可能是D:/Qt/Qt5.15.2/5.15.2/msvc2019_64/lib/cmake/Qt5,Linux下可能是/opt/Qt5.15.2/5.15.2/gcc_64/lib/cmake/Qt5。用户需要找到这个路径,并在CMake中设置CGAL_Qt5_DIR为该路径。 如果用户通过包管理器安装Qt5,可能需要安装额外的开发包,比如libqt5svg5-dev或者qtbase5-dev,这些可能包含所需的CMake文件。例如,在Ubuntu下,安装这些包可能解决路径问题。 另外,用户可能需要在CMake配置时显式启用Qt5支持。在配置CGAL时,可能有选项如WITH_CGAL_Qt5,需要设置为ON,否则CMake可能不会检查Qt5的相关路径。 总结可能的解决步骤: 1. 确认Qt5安装路径,并设置CGAL_Qt5_DIR为该路径下的CMake目录。 2. 检查是否安装了必要的Qt5开发包。 3. 确保CMake配置中启用了Qt5支持。 4. 如果使用CMake GUI,手动指定CGAL_Qt5_DIR的路径。 5. 在CMakeLists.txt中添加set命令,强制指定路径。 此外,可能需要查看CGAL的文档,确认其对Qt5版本的要求,以及是否需要其他依赖项。例如,CGAL的某些可视化组件可能需要Qt5的特定模块,如Qt5Svg、Qt5OpenGL等,用户需要确保这些模块已安装。 最后,用户可能需要重新运行CMake并清除缓存,确保路径正确加载。如果问题依旧,检查CMake的输出日志,查看具体的错误信息,进一步诊断缺失的组件或路径错误。</think>### DCGAL_Qt5_DIR 路径配置解决方案 1. **确认 Qt5 安装路径** - Windows 默认路径:`C:/Qt/5.15.2/msvc2019_64/lib/cmake/Qt5` - Linux 默认路径:`/opt/Qt5.15.2/5.15.2/gcc_64/lib/cmake/Qt5` - 若自定义安装,需通过Qt维护工具确认路径 2. **手动指定路径** - 在 CMake GUI 中手动设置 `CGAL_Qt5_DIR` 变量为上述路径 - 或在 CMakeLists.txt 添加: ```cmake set(CGAL_Qt5_DIR "您的实际Qt5路径/lib/cmake/Qt5") ``` 3. **验证 Qt5 依赖包** Linux系统需确保安装以下开发包: ```bash sudo apt-get install qtbase5-dev libqt5svg5-dev ``` 4. **启用 CGAL Qt5 支持** 在 CMake 配置中需显式启用选项: ```cmake set(WITH_CGAL_Qt5 ON) ``` 5. **清除 CMake 缓存** 删除 `CMakeCache.txt` 和 `CMakeFiles` 目录后重新生成 ### 典型错误排查流程 ```mermaid graph TD A[CMake报错找不到CGAL_Qt5_DIR] --> B{是否安装Qt5开发包?} B -->|否| C[安装qtbase5-dev等] B -->|是| D{路径是否正确?} D -->|否| E[手动设置CGAL_Qt5_DIR] D -->|是| F{是否启用WITH_CGAL_Qt5?} F -->|否| G[设置选项为ON] F -->|是| H[检查Qt版本兼容性] ``` ### 引用说明 Qt5模块路径设置方法与VTK配置类似,但需注意不同库的命名规范差异[^1][^2]。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值