gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04) 上编译问题笔记

编译错误如下:

In file included from /usr/include/glib-2.0/glib/glib-typeof.h:39,
                 from /usr/include/glib-2.0/glib/gatomic.h:28,
                 from /usr/include/glib-2.0/glib/gthread.h:32,
                 from /usr/include/glib-2.0/glib/gasyncqueue.h:32,
                 from /usr/include/glib-2.0/glib.h:32,
                 from ../libqemu/qemu-common.h:39,
                 from ../libqemu/qemu-aio.h:17,
                 from ../libqemu/block.h:4,
                 from ../libqemu/block_int.h:27,
                 from Block.h:6,
                 from Block.cpp:1:
/usr/include/c++/11/type_traits:1006:3: error: template with C linkage
 1006 |   template<typename _Tp>
      |   ^~~~~~~~
In file included from Block.cpp:1:
Block.h:4:1: note: ‘extern "C"’ linkage started here
    4 | extern "C"
      | ^~~~~~~~~~
In file included from /usr/include/glib-2.0/glib/glib-typeof.h:39,
                 from /usr/include/glib-2.0/glib/gatomic.h:28,
                 from /usr/include/glib-2.0/glib/gthread.h:32,
                 from /usr/include/glib-2.0/glib/gasyncqueue.h:32,
                 from /usr/include/glib-2.0/glib.h:32,
                 from ../libqemu/qemu-common.h:39,
                 from ../libqemu/qemu-aio.h:17,
                 from ../libqemu/block.h:4,
                 from ../libqemu/block_int.h:27,
                 from Block.h:6,
                 from Block.cpp:1:
/usr/include/c++/11/type_traits:1015:3: error: template with C linkage
 1015 |   template<typename _Tp, typename... _Args>
      |   ^~~~~~~~
In file included from Block.cpp:1:
Block.h:4:1: note: ‘extern "C"’ linkage started here
    4 | extern "C"
      | ^~~~~~~~~~
In file included from /usr/include/glib-2.0/glib/glib-typeof.h:39,
                 from /usr/include/glib-2.0/glib/gatomic.h:28,
                 from /usr/include/glib-2.0/glib/gthread.h:32,
                 from /usr/include/glib-2.0/glib/gasyncqueue.h:32,
                 from /usr/include/glib-2.0/glib.h:32,
                 from ../libqemu/qemu-common.h:39,
                 from ../libqemu/qemu-aio.h:17,
                 from ../libqemu/block.h:4,
                 from ../libqemu/block_int.h:27,
                 from Block.h:6,
                 from Block.cpp:1:
/usr/include/c++/11/type_traits:1021:3: error: template with C linkage
 1021 |   template<typename _Tp, typename... _Args>
      |   ^~~~~~~~
In file included from Block.cpp:1:

解决方法:

修改了Block.cpp,在其#include "Block.h"之前添加 #include <glib.h>

Ubuntu 22.04上安装特定版本的软件包,例如GCC、OpenVINO、OpenCV等,通常需要一些步骤来手动下载和配置。这里是一个概述: 1. **安装基础依赖** 首先更新系统并安装必要的包管理工具: ``` sudo apt update && sudo apt install build-essential cmake git libprotobuf-dev protobuf-compiler ``` 2. **安装GCC 11.4.0** Ubuntu 22.04默认已经包含了较新的GCC版本,如果你需要指定安装某个版本,可以通过添加第三方源,然后安装: ```bash sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt update sudo apt install g++-11 ``` 然后设置`g++-11`为默认版本: ```bash sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 90 --slave /usr/bin/g++-config g++-config /usr/bin/g++-11-config sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-11 90 --slave /usr/bin/c++-config c++-config /usr/bin/g++-11-config ``` 3. **安装OpenVINO 2021.4 (Test: 2023.0)** 下载对应版本的OpenVINO SDK并按照官方文档进行安装。官网地址通常是 https://docs.openvino.ai/latest 。注意,有些库可能需要单独安装。 4. **安装OpenCV 4.7.0** - 先安装基本依赖,如Python: ```bash sudo apt install python3-pip python3-dev swig ``` - 使用pip安装OpenCV: ```bash pip3 install opencv-python==4.7.0 ``` 或者从源代码编译安装: ```bash git clone https://github.com/opencv/opencv.git cd opencv mkdir release cd release cmake .. make -j4 sudo make install ``` 5. **安装其他依赖** - Eigen: 你可以通过Git克隆获取源码并编译安装,类似OpenCV的做法。 - Sophus, Glog, CeresSolver, Jsoncpp: 同样地,从GitHub克隆各自仓库,构建并安装。这些库大多数有详细的文档说明如何操作。 完成以上步骤后,确保每个库都在你的环境中可用,并确认它们的版本是否正确。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值