Using a C++ library with Julia 1.*.*


#1

In the index page of julialang.org is stated:

you can easily use libraries from Python, R, C/Fortran, C++, and Java

The C++ bit links to a library called Cxx that fails to install on Julia 1.0.0 and 1.0.2 and seems to no longer be maintained.

Is there any other way of using a C++ library with Julia?

Thank you.

P.S.: the julialang.org main page might need updating.


#2

Take a look at https://github.com/JuliaInterop/CxxWrap.jl.


#3

Hi Kristoffer, thank you for the reply. I have not given it a try, but CxxWrap looks like overkill. If it is necessary to compile extra shared libraries, and in turn load them in Julia, then it is possibly easier to simply programme everything in C++.

Cheers.


#4

I mean, that totally depends on what you are planning on doing. But sure, there is always some overhead with interlanguage programming and you have to evaluate if it makes sense based on your situation.


#5

You could use extern C, compile into a shared library, and then ccall the C++ functions exactly as you would C/Fortran code.


#6

I argue that Cxx.jl is (had been) such an awesome thing that the other solutions, while very valid, are not on par with it, at least for quick but intricate usage of existing C++ libraries.


#7

Some company who needs Cxx.jl should pay Juliacomputing to get it working again.


#8

Redefining private as public , for example:

    #define private public
    #include "clang/Parse/Parser.h"
    #undef private

is sin against good programming practice where punishment is (at least) hardly sustainable package.


#9

I can’t help but smile every time I see those lines :smile:

(edit: I say this with all the respect to Keno. I smile due to how cleverly but awfully one can hack C/C++ preparser.)


#10

If Cxx is so bad and unsustainable, then why is it linked from the julialang.org main page with the claim that Julia integrates with C++?


#11

There are some people here on the forums that unfortunately seem to try their best to inject poison into most of the thread they comment in. Personally, I think it is best to ignore such people.

From what I have heard, Cxx is in progress of getting updated so I don’t think there is a need for a great deal of worry.


#12

It’s not unsustainable, it just hasn’t been updated yet and there are other work items that are more important for the compiler team to work on at the moment. You can use CxxWrap as well, which already supports Julia 1.0.


#13

I have to agree that @Luis_de_Sousa’s comment seems really unnecessarily unpleasant and toxic. This is the kind of thing that makes supporting open source projects so very unpleasant sometimes. Please reconsider your tone and attitude about the projects that you use for free.


#14

That would be great news. Any resource that could be referenced on that? Or where I could follow progress? Over at GitHub there are a couple of issues open on maintenance, but none has been answered.

Cheers.


#15

Interesting, I understood this package was put together by a third party, but is it now abridged by the core developers? This would explain why it is so quiet over at GitHub. Can you clarify?

Thank you.


#16

Please read the thread again, the “poison” remark was not directed at me. I fail to see where have I been unpleasant, let alone toxic.

Cheers.


#17

@keno developed and maintains Cxx. He is one of the core members of Julia’s compiler team and a co-founders of Julia Computing. He’s fairly busy these days, working on, among other things: Julia’s TPU support, getting Julia’s debugger working on Julia 1.0, and eventually getting Cxx working on Julia 1.0, not to mention being on the Forbes 30 under 30 list. There are other people—not that many, however, and they would need to spend a lot more time learning things—who could potentially do some of this work but they’re also busy working on other things, which is why I made a post giving a rough sense of the priorities of the compiler team.


#18

My apologies if you didn’t mean it that way, and yes, I see that you were not the one who started talking about Cxx being “unmaintainable” and criticizing the way it works (which is fairly unavoidable since it needs to be able to access the private members of C++ data structures).


#19

I don’t see Cxx.jl as bad I see it as state of art!

As we could see - not easy maintainable.

Unmaintanability was hyperbole about sin and punishment. But one don’t need to be genius to see that “stealing” private members of data structures from foreign libraries is dangerous and code much more probably won’t be compatible with future versions of these libraries. (Which is what we observe now?).

Thanks for returning Cxx.jl officially into priorities! Could you guess when it will be ready?


#20

LLVM/Clang have no guarantees on either their public or private APIs, so this distinction is more of an aesthetic choice for them. However, if you would like to volunteer or fund the work required to introduce public abstractions that contain the necessary functionality, you’re most welcome to do so.