Using Boost

382 views
Skip to first unread message

Emil Dotchevski

unread,
May 15, 2017, 3:09:17 PM5/15/17
to The Meson Build System
First let me say I find Meson's design to be great but I'm having difficulties getting it to work.

One obstacle for me is how do I get it to use Boost? If I understand correctly, it's not in the wrapdb, and it seems it requires pkg-config. But what if I don't have it? I tried running the "test cases/frameworks/1 boost" unit test and it doesn't work on my macOS system (I also need it to work on Windows and Linux.)

I also tried to create my own wrap file, after all it's not the end of the world if I have to manually hook up boost libs. I put the following boost/meson.build into ~/Desktop/mesonwraps/boost.tar.gz:

project('boost', 'cpp', license:'boost')

if not meson.is_subproject()
    error('The meson support for Boost is designed for Boost as a subproject')
endif

boost_includes = include_directories('include')
boost_defines = ['-DBOOST_ALL_NO_LIB=1']

headers = declare_dependency(include_directories: boost_includes)

system = declare_dependency(
    include_directories: boost_includes,
    link_with: static_library('boost-system','libs/system/src/error_code.cpp'),
    compile_args: '-DBOOST_SYSTEM_STATIC_LINK=1' + boost_defines
)

Then in ~Desktop/mesontest I've got a project with the following boost.wrap in a subdirectory called subprojects:

[wrap-file]
directory=boost

source_url = https://dl.bintray.com/boostorg/release/1.64.0/source/boost_1_64_0.tar.gz
source_filename = boost_1_64_0.tar.gz
source_hash = 0445c22a5ef3bd69f5dfb48354978421a85ab395254a26b1ffb0aa1bfd63a108

patch_url = file://~/Desktop/mesonwraps/boost.tar.gz
patch_filename = boost.tar.gz
patch_hash = f12963d83d9751e43389394a7e9f940396f60ae1a3070c186df900ecfb63b361

When build, I get the following:

Version: 0.40.1
Source dir: /Users/<redacted>/Desktop/mesontest/repo1
Build dir: /Users/<redacted>/Desktop/mesontest/repo1/bld
Build type: native build
Project name: repo1
Native cpp compiler: c++ (clang 8.1.0)
Build machine cpu family: x86_64
Build machine cpu: x86_64
Using boost from cache.
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 298, in run
    app.generate()
  File "/usr/local/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 180, in generate
    intr.run()
  File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 2504, in run
    super().run()
  File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 125, in run
    self.evaluate_codeblock(self.ast, start=1)
  File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 146, in evaluate_codeblock
    raise e
  File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 140, in evaluate_codeblock
    self.evaluate_statement(cur)
  File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 153, in evaluate_statement
    return self.assignment(cur)
  File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 566, in assignment
    value = self.evaluate_statement(node.value)
  File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 151, in evaluate_statement
    return self.function_call(cur)
  File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 372, in function_call
    return self.funcs[func_name](node, self.flatten(posargs), kwargs)
  File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 55, in wrapped
    return f(self, node, args, kwargs)
  File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 1508, in func_subproject
    return self.do_subproject(dirname, kwargs)
  File "/usr/local/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 1520, in do_subproject
    resolved = r.resolve(dirname)
  File "/usr/local/lib/python3.6/site-packages/mesonbuild/wrap/wrap.py", line 143, in resolve
    self.extract_package(p)
  File "/usr/local/lib/python3.6/site-packages/mesonbuild/wrap/wrap.py", line 325, in extract_package
    shutil.unpack_archive(os.path.join(self.cachedir, package.get('patch_filename')), self.subdir_root)
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/shutil.py", line 977, in unpack_archive
    func(filename, extract_dir, **kwargs)
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/shutil.py", line 910, in _unpack_tarfile
    tarobj = tarfile.open(filename)
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tarfile.py", line 1568, in open
    return func(name, "r", fileobj, **kwargs)
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tarfile.py", line 1633, in gzopen
    fileobj = gzip.GzipFile(name, mode + "b", compresslevel, fileobj)
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/gzip.py", line 163, in __init__
    fileobj = self.myfileobj = builtins.open(filename, mode or 'rb')
FileNotFoundError: [Errno 2] No such file or directory: '/Users/<redacted>/Desktop/mesontest/repo1/subprojects/packagecache/boost.tar.gz'

What am I doing wrong?

Thanks!
Emil

Jussi Pakkanen

unread,
May 15, 2017, 3:19:59 PM5/15/17
to Emil Dotchevski, The Meson Build System
On Mon, May 15, 2017 at 10:09 PM, Emil Dotchevski
<emildot...@gmail.com> wrote:

> One obstacle for me is how do I get it to use Boost? If I understand
> correctly, it's not in the wrapdb, and it seems it requires pkg-config. But
> what if I don't have it? I tried running the "test cases/frameworks/1 boost"
> unit test and it doesn't work on my macOS system (I also need it to work on
> Windows and Linux.)

The Boost dependency resolver does work on Windows and Linux, those
have been tested. The dependency does not use pkg-config because Boost
does not ship pkg-config files. If any Boost developers are reading
this, please, please start shipping .pc files. The current situation
is awful for integration.

On OSX the problem is that there is no officially sanctioned place to
place Boost files so they can be anywhere. In this case you need to
point Meson to the install path with the BOOST_ROOT environment
variable. If that does not detect it then that is a bug that needs
fixing.

Emil Dotchevski

unread,
May 15, 2017, 3:34:32 PM5/15/17
to The Meson Build System, emildot...@gmail.com
On Monday, May 15, 2017 at 12:19:59 PM UTC-7, Jussi Pakkanen wrote:
On OSX the problem is that there is no officially sanctioned place to
place Boost files so they can be anywhere. In this case you need to
point Meson to the install path with the BOOST_ROOT environment
variable. If that does not detect it then that is a bug that needs
fixing.

This is very helpful but doesn't that mean that on OSX I can't have meson automatically download boost? Note, I don't need it installed, I link it statically.

At any rate, it should also work if I do my own wrap file, correct? What was I doing wrong in that attempt? This is important for me because I was planning to hook up my own and several 3rd party libraries as wraps that just know where to get them from. If I have several git repositories (which don't know about Meson), how can I configure a project to automatically clone them as subprojects and use Meson.build files that I create for each one of them (and store elsewhere?)

Jussi Pakkanen

unread,
May 15, 2017, 7:28:32 PM5/15/17
to Emil Dotchevski, The Meson Build System
On Mon, May 15, 2017 at 10:34 PM, Emil Dotchevski
<emildot...@gmail.com> wrote:

> This is very helpful but doesn't that mean that on OSX I can't have meson
> automatically download boost? Note, I don't need it installed, I link it
> statically.
>
> At any rate, it should also work if I do my own wrap file, correct? What was
> I doing wrong in that attempt? This is important for me because I was
> planning to hook up my own and several 3rd party libraries as wraps that
> just know where to get them from. If I have several git repositories (which
> don't know about Meson), how can I configure a project to automatically
> clone them as subprojects and use Meson.build files that I create for each
> one of them (and store elsewhere?)

Based on the log I'd guess that Python's urllib has trouble dowloading
your file. If you copy it to the file to the packagecache directory
manually, it should skip the download and try to use it directly.
Reply all
Reply to author
Forward
0 new messages