Using a C++ library with Julia 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 Likes

Take a look at GitHub - JuliaInterop/CxxWrap.jl: Package to make C++ libraries available in Julia.

1 Like

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.

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.

1 Like

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

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.

4 Likes

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

3 Likes

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.

1 Like

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.)

3 Likes

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++?

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.

4 Likes

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.

2 Likes

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.

2 Likes

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.

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.

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.

2 Likes

@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.

1 Like

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).

5 Likes

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?

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.

1 Like