ubuntu 安装/升级 cmake (& cmake-gui)

本文详细介绍如何在系统中同时安装并配置Qt4和Qt5,以满足CMake-GUI的需求。包括安装Qt4,设置默认Qt版本,下载CMake源码,卸载旧版CMake,编译安装新版CMake的步骤。

一. cmake-gui需要 qt4,需要先安装qt4

sudo apt-get install qt4*

有时候需要qt4,qt5共存,设置默认qt版本的方法:
1.查看系统已安装的qt

ls -l /usr/lib/x86_64-linux-gnu/qt*

显示如下:

/usr/lib/x86_64-linux-gnu/qt4:
total 12
drwxr-xr-x  2 root root 4096 8月  22 19:10 bin
drwxr-xr-x  3 root root 4096 8月  22 19:09 imports
drwxr-xr-x 16 root root 4096 5月  17  2018 plugins

/usr/lib/x86_64-linux-gnu/qt5:
total 16
drwxr-xr-x  2 root root 4096 7月  20  2016 bin
drwxr-xr-x  2 root root 4096 7月  20  2016 libexec
drwxr-xr-x 16 root root 4096 7月  20  2016 plugins
drwxr-xr-x 11 root root 4096 7月  20  2016 qml

/usr/lib/x86_64-linux-gnu/qtchooser:
total 0
lrwxrwxrwx 1 root root 50 5月  17  2018 4.conf -> ../../../share/qtchooser/qt4-x86_64-linux-gnu.conf
lrwxrwxrwx 1 root root 50 2月  12  2019 5.conf -> ../../../share/qtchooser/qt5-x86_64-linux-gnu.conf
lrwxrwxrwx 1 root root 50 4月   5  2016 default.conf -> ../../../share/qtchooser/qt4-x86_64-linux-gnu.conf
lrwxrwxrwx 1 root root 50 5月  17  2018 qt4.conf -> ../../../share/qtchooser/qt4-x86_64-linux-gnu.conf
lrwxrwxrwx 1 root root 50 2月  12  2019 qt5.conf -> ../../../share/qtchooser/qt5-x86_64-linux-gnu.conf

/usr/lib/x86_64-linux-gnu/qt-default:
total 4
drwxr-xr-x 2 root root 4096 7月  20  2016 qtchooser
frizy@frizy:~$ cat /usr/lib/x86_64-linux-gnu/qt-default/
cat: /usr/lib/x86_64-linux-gnu/qt-default/: Is a directory
frizy@frizy:~$ cat /usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf 
/usr/lib/x86_64-linux-gnu/qt4/bin
/usr/lib/x86_64-linux-gnu
frizy@frizy:~$ ls -l /usr/lib/x86_64-linux-gnu/qt*
/usr/lib/x86_64-linux-gnu/qt4:
total 12
drwxr-xr-x  2 root root 4096 8月  22 19:10 bin
drwxr-xr-x  3 root root 4096 8月  22 19:09 imports
drwxr-xr-x 16 root root 4096 5月  17  2018 plugins

/usr/lib/x86_64-linux-gnu/qt5:
total 16
drwxr-xr-x  2 root root 4096 7月  20  2016 bin
drwxr-xr-x  2 root root 4096 7月  20  2016 libexec
drwxr-xr-x 16 root root 4096 7月  20  2016 plugins
drwxr-xr-x 11 root root 4096 7月  20  2016 qml

/usr/lib/x86_64-linux-gnu/qtchooser:
total 0
lrwxrwxrwx 1 root root 50 5月  17  2018 4.conf -> ../../../share/qtchooser/qt4-x86_64-linux-gnu.conf
lrwxrwxrwx 1 root root 50 2月  12  2019 5.conf -> ../../../share/qtchooser/qt5-x86_64-linux-gnu.conf
lrwxrwxrwx 1 root root 50 4月   5  2016 default.conf -> ../../../share/qtchooser/qt4-x86_64-linux-gnu.conf
lrwxrwxrwx 1 root root 50 5月  17  2018 qt4.conf -> ../../../share/qtchooser/qt4-x86_64-linux-gnu.conf
lrwxrwxrwx 1 root root 50 2月  12  2019 qt5.conf -> ../../../share/qtchooser/qt5-x86_64-linux-gnu.conf

/usr/lib/x86_64-linux-gnu/qt-default:
total 4
drwxr-xr-x 2 root root 4096 7月  20  2016 qtchooser

查看默认的qt版本:

cat /usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf

显示如下:

/usr/lib/x86_64-linux-gnu/qt4/bin
/usr/lib/x86_64-linux-gnu

更改 /usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf 里第一行qt4 / qt5 切换默认的qt版本。

二.下载cmake源码

https://cmake.org/download/
Unix/Linux Source (has \n line feeds)

三.卸载旧版本cmake

sudo apt-get remover cmake*

四.编译安装新版本

tar xvf cmake-3.*.tar.gz
cd cmake-3.*
./configure --qt-gui
make -j4
sudo make install

四.检查

cmake --version
cmake-gui --version
我这个dockerfile 创建的docker 里面为什么会有一个gcc FROM ubuntu:18.04 LABEL Authors="Kun Liu <liukun@tp-link.com.hk> " LABEL Description="Broadcom SDK Build based on 18.04 LTS" Version="1.0" ENV STAGINGDIR="" ENV CONFIGDIR="" ENV PACKAGEDIR="" RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections RUN apt-get clean && \ apt-get update && \ apt-get install --yes \ --no-install-recommends \ --no-install-suggests \ build-essential net-tools inetutils-ping \ libncurses5-dev libdigest-crc-perl libpopt-dev xxd \ liblzo2-dev zlib1g-dev lib32z1 \ libssl-dev libglib2.0-dev libreadline-dev \ libjson-c-dev libxml2-dev \ libsqlite3-dev sqlite3 \ libuv1-dev libxslt1-dev libfcgi-dev \ libevent-dev libyajl-dev liburiparser-dev libwebsockets-dev \ locales lua5.1 liblua5.1-dev \ python python3 python3-dev python3-pip \ git git-lfs \ subversion \ autoconf automake \ pkg-config ccache \ cmake ninja-build \ clang-tools-6.0 \ bison flex gettext \ ca-certificates \ libtool patch vim \ unzip uuid-dev \ wget curl cpio \ bc gawk \ gdb valgrind diffstat \ chrpath texinfo \ ssh openssh-client openssh-server netbase \ quilt protobuf-c-compiler dropbear-bin openvswitch-switch \ tmux dirmngr lighttpd alien \ mlocate iproute2 dos2unix \ lsb-release \ rsync \ gdisk \ man \ pax \ moreutils \ python3-dev \ python3-setuptools \ sudo RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - && \ apt-get install -y --no-install-recommends nodejs # ← 兼容修改:Ubuntu 18.04 使用 clang-tools-6.0 而非 clang-tools # ← 兼容修改:liblua5.3-dev 在 bionic 中版本太旧,默认不安装 # ← 兼容修改:python/pip 默认 Python 3.6 # Enable 32-bit program execution on 64bit system RUN dpkg --add-architecture i386 && \ apt-get update && \ apt-get install --yes \ --no-install-recommends \ --no-install-suggests \ libc6:i386 libncurses5:i386 libstdc++6:i386 libc6-dev:i386 \ libselinux1:i386 gcc-multilib g++-multilib # Install Runtime debugging tools and Java environment RUN apt-get update && \ apt-get install --yes \ --no-install-recommends \ --no-install-suggests \ strace openjdk-8-jdk-headless # Add BRCM cross-tc gcc10 dependency and openwrt cmake fixing RUN rm /bin/sh && ln -sf bash /bin/sh && \ ln -s /usr/bin/perl /usr/local/bin/perl && \ ln -sf /usr/lib/x86_64-linux-gnu/libreadline.so /usr/lib/x86_64-linux-gnu/libreadline.so.7 # ← 兼容修改:bionic 的 libreadline.so 是 .so.7,而非 .so.6 ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 ENV TERM xterm-256color ENV LANG=C.UTF-8 ENV LD_LIBRARY_PATH /usr/local/lib # COPY fs_resources/ / # RUN chmod 644 /etc/sudoers RUN pip3 install --no-cache-dir -i https://pypi.tuna.tsinghua.edu.cn/simple \ gdbgui==0.13.2.0 \ kconfiglib pydot jinja2 pyyaml #RUN pip3 install --no-cache-dir -i https://pypi.tuna.tsinghua.edu.cn/simple gdbgui kconfiglib pydot jinja2 pyyaml RUN cd ~ RUN apt-get -q -y autoremove && \ rm -rf /var/lib/apt/lists/* /var/tmp/* /tmp/* #RUN curl https://storage.googleapis.com/git-repo-downloads/repo > ~/repo && \ # chmod a+x ~/repo && chown 0:0 ~/repo && mv ~/repo /usr/bin/repo RUN apt-get update && \ apt-get install -y software-properties-common gnupg wget && \ wget -q -O - https://apt.kitware.com/keys/kitware-archive-latest.asc | gpg --dearmor - > /etc/apt/trusted.gpg.d/kitware.gpg && \ apt-add-repository "deb https://apt.kitware.com/ubuntu/ bionic main" && \ apt-get update && \ apt-get install -y cmake # 验证CMake版本 RUN cmake --version RUN git clone https://git.openwrt.org/project/libubox.git && \ git clone https://git.openwrt.org/project/ubus.git && \ cd libubox && cmake . && make && make install && \ cd ../ubus && cmake . && make && make install && \ cd .. && rm -rf libubox ubus && mkdir -p /var/run/ubus RUN wget https://github.com/warmcat/libwebsockets/archive/refs/tags/v4.2.2.tar.gz -O lws.tar.gz && \ tar -xzf lws.tar.gz && \ cd libwebsockets-4.2.2 && \ mkdir build && cd build && \ cmake .. -DLWS_WITH_LIBUV=1 && \ make -j$(nproc) && make install && \ cd ../.. && \ rm -rf lws.tar.gz libwebsockets-4.2.2 #RUN git clone https://github.com/warmcat/libwebsockets.git && \ #cd libwebsockets && git checkout v4.2.2 && mkdir build && cd build && \ #cmake .. -DLWS_WITH_LIBUV=1 && make && make install && \ #cd ../../ && rm -rf libwebsockets RUN wget https://github.com/c-ares/c-ares/releases/download/cares-1_17_2/c-ares-1.17.2.tar.gz && \ tar -xzf c-ares-1.17.2.tar.gz && \ cd c-ares-1.17.2 && \ ./configure --prefix=/usr --disable-static && \ make && make install && \ cd .. && \ rm -rf c-ares-1.17.2 c-ares-1.17.2.tar.gz #RUN git clone https://github.com/c-ares/c-ares.git && \ # cd c-ares && git checkout cares-1_17_2 && \ # ./buildconf && ./configure --prefix=/usr --disable-static && \ # make && make install && cd ../ && rm -rf c-ares # To build prplos # RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - && \ # apt-get update && apt-get install --yes nodejs && \ # npm install -g ember-cli # ← 兼容修改:bionic 对 Node.js 16 支持差,改为 Node.js 14 RUN mkdir /data #CMD ["/usr/local/bin/init.sh"]
11-08
CMake Error at /usr/lib/aarch64-linux-gnu/cmake/Qt5Gui/Qt5GuiConfig.cmake:26 (message): The imported target "Qt5::Gui" references the file "/usr/lib/aarch64-linux-gnu/qt5/plugins/xcbglintegrations/libqxcb-glx-integration.so" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/aarch64-linux-gnu/cmake/Qt5Gui/Qt5Gui_QXcbGlxIntegrationPlugin.cmake" but not all the files it references. Call Stack (most recent call first): /usr/lib/aarch64-linux-gnu/cmake/Qt5Gui/Qt5GuiConfig.cmake:231 (_qt5_Gui_check_file_exists) /usr/lib/aarch64-linux-gnu/cmake/Qt5Gui/Qt5Gui_QXcbGlxIntegrationPlugin.cmake:5 (_populate_Gui_plugin_properties) /usr/lib/aarch64-linux-gnu/cmake/Qt5Gui/Qt5GuiConfig.cmake:240 (include) /usr/lib/aarch64-linux-gnu/cmake/Qt5Widgets/Qt5WidgetsConfig.cmake:111 (find_package) /usr/lib/aarch64-linux-gnu/cmake/Qt5OpenGL/Qt5OpenGLConfig.cmake:111 (find_package) /usr/lib/aarch64-linux-gnu/cmake/Qt5/Qt5Config.cmake:28 (find_package) /usr/lib/aarch64-linux-gnu/cmake/vtk-9.1/VTK-vtk-module-find-packages.cmake:1008 (find_package) /usr/lib/aarch64-linux-gnu/cmake/vtk-9.1/vtk-config.cmake:150 (include) /usr/lib/aarch64-linux-gnu/cmake/pcl/PCLConfig.cmake:270 (find_package) /usr/lib/aarch64-linux-gnu/cmake/pcl/PCLConfig.cmake:319 (find_VTK) /usr/lib/aarch64-linux-gnu/cmake/pcl/PCLConfig.cmake:540 (find_external_library) /opt/ros/humble/share/pcl_conversions/cmake/ament_cmake_export_dependencies-extras.cmake:21 (find_package) /opt/ros/humble/share/pcl_conversions/cmake/pcl_conversionsConfig.cmake:41 (include) CMakeLists.txt:12 (find_package)
最新发布
11-13
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值