# Suggestions to partially compile the ./math component into Julia \_jll library

**URL:** <https://root-forum.cern.ch/t/suggestions-to-partially-compile-the-math-component-into-julia-jll-library/56485>\
**Category:** Newbie\
**Created:** [September 26, 2023, 4:23am UTC](https://root-forum.cern.ch/t/suggestions-to-partially-compile-the-math-component-into-julia-jll-library/56485 "2023-09-26T04:23:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ylian](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ylian/32/34580_2.png) [@ylian](https://root-forum.cern.ch/u/ylian)\
**Post date:** [September 26, 2023, 4:23am UTC](https://root-forum.cern.ch/t/suggestions-to-partially-compile-the-math-component-into-julia-jll-library/56485/1 "2023-09-26T04:23:00Z")

</div>

Dear developers and experts,

I want to make the Root math functions accessible from Julia. The way to do it is, I guess, to have a successful minimal compilation of the source code in the `./math` folder and then go over the procedures with `BinaryBuilder.jl` [1] on the Julia side. But I really don’t have a clue on how to start. The `cmake` files are too complicated for me to understand. I wish to get some general guidelines on how to compile the math component into a minimal dynamic library, with some properly written cmake files.

[1] Julia BindaryBuilder.jl is a facility to wrap and build C/C++ source code into libraries which are accessible from Julia. I cannot put links in the post, sorry.

Best,  
Yunlong

---

<div class="post-metadata">

**Author:** ![jonas](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jonas/32/24756_2.png) [@jonas](https://root-forum.cern.ch/u/jonas)\
**Post date:** [September 27, 2023, 12:54pm UTC](https://root-forum.cern.ch/t/suggestions-to-partially-compile-the-math-component-into-julia-jll-library/56485/2 "2023-09-27T12:54:55Z")

</div>

Hi @ylian, welcome to the ROOT forum!

Interesting idea 👍 You don’t need to understand the ROOT CMake files to do this however.

What I would do here is to write new CMake files that use the same sources, but compile the math part standalone, maybe starting with `math/mathcore`. There is some example for this already in [`math/minuit2`](https://github.com/root-project/root/tree/master/math/minuit2) actually, which also contains CMake files to build Minuit2 standalone!

Another example of a custom CMakeFile that compiles sources from the ROOT repository is the one in [iminuit](https://github.com/scikit-hep/iminuit/blob/develop/CMakeLists.txt).

But even if you write your custom CMake files, then you’ll still have to deal with the dependency of `math` on the rest of ROOT before building `math` standalone. For example, mathcore uses the ROOT error logging and some classes inherit from TObject. The other math libraries sometimes even use ROOT histograms.

So what I would do is to follow the model of the iminuit developers and only compile a the limited subset of ROOT Math sources that you actually need in your project, maybe fixing the occasional ROOT dependency problem by changing the code itself (e.g., the TObject base class of TRandom could probably easily removed in your “fork” of ROOT math).

If you find good solutions to all of that, feel free to contribute your standalone build files back to ROOT, just like they are available for Minuit2! There are other users who would like to do the same thing:

> <https://github.com/root-project/root/issues/6617>
>
> I would like to have a posibility to build only the math libraries or that they …are split out from the main project, as we don't want to use root as an application but are writing simulations in c++ and would not like to build our own math lib. 
> 
> At the moment it is possible to build the math libs one by one but the c++ interpreter is build as a dependency of them (also some dependency that uses openssl) which is not needed to use the pure math libs. This increases build times unreasonably.
> 
> I just build the MathMore target. For this Target about 97% of the compile steps where made up of compiling the interpretor.

I hope I could give you some ideas though.

Cheers,  
Jonas

---

<div class="post-metadata">

**Author:** ![ylian](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ylian/32/34580_2.png) [@ylian](https://root-forum.cern.ch/u/ylian)\
**Post date:** [October 10, 2023, 9:21am UTC](https://root-forum.cern.ch/t/suggestions-to-partially-compile-the-math-component-into-julia-jll-library/56485/3 "2023-10-10T09:21:40Z")

</div>

Hi @jonas , thanks for the nice tutorial. I am still doing the “homework”. Come back later!
