JLL library: how to use boost_jll

Hi,
Is there a simple example on how to use the boost_jll library?

1/ I would like for example to use boost::sort::block_indirect_sort in #include <boost/sort/sort.hpp>. There is a C++ example here:
https://cppsecrets.com/users/1442971101051149897110100971154850485464103109971051084699111109/C00-boostsortblockindirectsort.php

2/ I also tried to use file_size from boost::filesystem like that

using boost_jll
ccall((:file_size, libboost_filesystem), Cint, (Cstring,), "D:/bo.txt")
ERROR: could not find symbol "file_size"

Would anyone be able to provide help on how to make these example work?
I know these can easily be done in pure Julia but I just want to understand how to use these jll package.

Thank you

Boost is a C++, not a C library. The C++ compiler generates different symbols than a C compiler would.

The JuliaCon2020 video about CxxWrap.jl explains the issue.

1 Like

Yes I know it is C++ and tried CxxWrap as well (on windows with Julia 1.7) and it does not work either.

Julia C++ support does not seem to be mature yet. I guess I will have to stick with Python/R for now.

I thought CxxWrap.jl just works?! And only good option now (other than calling indirectly to C++ through e.g. Python (there’s a thread on that), or using extern C in C++).

It’s of course not Julia’s responsibility to support C++, and I think you know that, nor clear you meant that.

I haven’t looked into what your issue is with CxxWrap.jl, it should work in 1.6.x. Julia 1.7 is of course not released yet (while very close), can you check if 1.6 works in case 1.7 breaks it (I don’t think it should, also unclear to me it could).

Cxx.jl used to work in supported Julia versions (you could try e.g. Julia 1.3 with it, it would just be informative). In that case Julia could and in a sense did break the package (strictly its updated LLVM dependency did it):

I’m also intrigued about this new (to me) sorting algorithm in Boost, you might like to know of other interesting, seemingly to me best:

How fast is that Blitsort vs Julia base sort? It is multi-threaded? It does not look so.
On my old mac, I have the following under Julia 1.6.0:

using BenchmarkTools
x = rand(100_000_000);
@btime sort(x);
11.311 s (2 allocations: 762.94 MiB)

I have written a sorting algo in C that I use in R/Python/Julia which give me the following:

> x = runif(1e8)
> microbenchmark::microbenchmark(a = psort(x, nThread = 1L), times = 5L)
Unit: seconds
 expr      min       lq    mean   median       uq     max neval
    a 5.322546 5.385898 5.47175 5.480402 5.583312 5.58659     5
> microbenchmark::microbenchmark(a = psort(x, nThread = 2L), times = 5L)
Unit: seconds
 expr      min       lq     mean   median       uq      max neval
    a 2.973096 2.979794 3.017712 2.981372 3.014734 3.139564     5

I can also post the timings for boost::sort::block_indirect_sort using Rcpp if needed.