I'm currently trying to set up a C++ library inside a vagrant ubuntu/xenial32 virtual machine. The build system that I choose for this project was meson 0.50. My Vagrantfile is:
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial32"
config.vm.provision "file", source: "./mint/", destination: "/home/vagrant/mint"
config.vm.provision :shell, path: "bootstrap.sh"
end
and my bootstrap is described as follows:
sudo apt-get update && sudo apt-get -y upgrade && sudo apt-get install -y \
build-essential \
cmake \
curl \
libboost-all-dev \
libzmq3-dev \
gcc-multilib \
git-core \
pkg-config \
python3 python3-pip python3-setuptools \
python3-wheel ninja-build
wget https://github.com/mesonbuild/meson/releases/download/0.50.0/meson-0.50.0.tar.gz
tar -xf meson-0.50.0.tar.gz
cd meson-0.50.0/
sudo python3 setup.py install
cd /home/vagrant/
cd mint/
sudo meson build --prefix=/usr/
sudo meson configure -Dcpp_std=c++11 build/
sudo meson install -C build/
As for the C++ library, the meson.build file is:
project('mint', 'cpp', version: '0.2.1')
cxx = meson.get_compiler('cpp')
math = cxx.find_library('m', required: false)
headers = include_directories('include')
sources = files([
'src/mint-quality.cpp',
])
mint = library(
meson.project_name(),
sources,
include_directories: headers,
dependencies: math,
install: true
)
mint_dep = declare_dependency(
include_directories: headers,
link_with: mint
)
public_headers = files([
'include/mint/mint-quality.h',
])
install_headers(public_headers, subdir: meson.project_name())
And finally the header and cpp files:
#ifndef __MINT_QUALITY_H__
#define __MINT_QUALITY_H__
#include <string>
#include <vector>
#include <array>
#include <cstdint>
#include <cstdlib>
namespace Mint {
typedef uint8_t Electrode;
typedef uint16_t Perimeter;
enum class Status : uint8_t {
NORMAL,
LOOSE,
BROKEN
};
class Mint {
public:
Mint();
Mint(std::vector<Status> electrodes);
bool
operator==(const Quality& other) const;
private:
std::vector<Status> _electrodes;
};
}
#endif // __MINT_QUALITY_H__
#include <cstdlib>
#include <mint/mint-quality.h>
namespace Mint {
Quality::Quality() {}
Quality::Quality(std::vector<Status> electrodes)
: _electrodes(electrodes)
{}
}
But when I run the vagrant up
command, it gives me a compilation error related to the last line of the bootstrap file. From what I understood, this error happened because the c++ version used was a version older than the c++11, which shouldn't happen, since I specified the c++11 version with the sudo meson configure -Dcpp_std=c++11 build/
command.
default: Processing dependencies for meson==0.50.0
default: Finished processing dependencies for meson==0.50.0
default: The Meson build system
default: Version: 0.50.0
default: Source dir: /home/vagrant/mint
default: Build dir: /home/vagrant/mint/build
default: Build type: native build
default: Project name: mint
default: Project version: 0.2.1
default: Native C++ compiler: c++ (gcc 5.4.0 "c++ (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609")
default: Build machine cpu family: x86
default: Build machine cpu: i686
default: Library m found: YES
default: Build targets in project: 1
default: Found ninja-1.5.1 at /usr/bin/ninja
default: ninja: Entering directory `build/'
default: [1/2] Compiling C++ object 'mint@sha/src_mint-quality.cpp.o'.
default: FAILED: c++ -Imint@sha -I. -I.. -I../include -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -g -fPIC -MD -MQ 'mint@sha/src_mint-quality.cpp.o' -MF 'mint@sha/src_mint-quality.cpp.o.d' -o 'mint@sha/src_mint-quality.cpp.o' -c ../src/mint-quality.cpp
default: In file included from /usr/include/c++/5/cstdint:35:0,
default: from ../include/mint/mint-quality.h:4,
default: from ../src/mint-quality.cpp:2:
default: /usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
default: #error This file requires compiler and library support \
The weird thing is: when I run vagrant provision
right after this error occurred, the C++ library was installed with no problems. What could be the cause of this error, and how should I solve it without modifying the inner workings of my C++ application (without changing my meson.build)
Aucun commentaire:
Enregistrer un commentaire