Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ wrapping tutorial #132

Closed
TeroFrondelius opened this issue Jun 7, 2015 · 4 comments
Closed

C++ wrapping tutorial #132

TeroFrondelius opened this issue Jun 7, 2015 · 4 comments
Labels

Comments

@TeroFrondelius
Copy link

Hi,
I have been couples of days learning (struggling) Clang.jl. I like the idea and I think this package could really boost scientific calculations, when people could be building on top of existing libraries.

First really hard part was to get the package to building. I used this this type of trick (found somewhere else):

Pkg.checkout("Clang","master")
Pkg.build("Clang")

Secondly I tried to follow this https://github.com/ihnorton/Clang.jl#implementation
That really haven't helped so far, the ratio between code complexity and commenting is above my skills.

Then I looked the tests and I thought I found something useful: https://github.com/ihnorton/Clang.jl/blob/master/test/test_classparents.jl
The problem is that it's not doing enough to work as a tutorial.

Also the current documentation is not really helping, when the whole wrap_cpp is missing from there.

If I could get this type of tutorial for c++, it really would help to the start

using Clang.wrap_c

context = wrap_c.init(; output_file="libjpeg.jl", header_library=x->"libjpeg", common_file="libjpeg_h.jl", clang_diagnostics=true)
context.options.wrap_structs = true
wrap_c.wrap_c_headers(context, ["/usr/include/jpeglib.h"])
@ihnorton
Copy link
Collaborator

ihnorton commented Jun 7, 2015

check out github.com/Keno/Cxx.jl for the industrial-strength version.

On Sun, Jun 7, 2015 at 11:57 AM, Tero Frondelius [email protected]
wrote:

Hi,
I have been couples of days learning (struggling) Clang.jl. I like the
idea and I think this package could really boost scientific calculations,
when people could be building on top of existing libraries.

First really hard part was to get the package to building. I used this
this type of trick (found somewhere else):

Pkg.checkout("Clang","master")
Pkg.build("Clang")

Secondly I tried to follow this
https://github.com/ihnorton/Clang.jl#implementation
That really haven't helped so far, the ratio between code complexity and
commenting is above my skills.

Then I looked the tests and I thought I found something useful:
https://github.com/ihnorton/Clang.jl/blob/master/test/test_classparents.jl
The problem is that it's not doing enough to work as a tutorial.

Also the current documentation is not really helping, when the whole
wrap_cpp is missing from there.

If I could get this type of tutorial for c++, it really would help to the
start

using Clang.wrap_c

context = wrap_c.init(; output_file="libjpeg.jl", header_library=x->"libjpeg", common_file="libjpeg_h.jl", clang_diagnostics=true)
context.options.wrap_structs = true
wrap_c.wrap_c_headers(context, ["/usr/include/jpeglib.h"])


Reply to this email directly or view it on GitHub
#132.

@TeroFrondelius
Copy link
Author

Thanks. I actually started by Cxx.jl. I just couldn't get Julia to compile with all those needed stuff. I gave up after three long nights. Maybe I will give another try.

@stemann
Copy link
Contributor

stemann commented Aug 13, 2017

Do Cxx provide an automatic wrapper generator?

Clang.jl fails to parse/translate/wrap the following C++ enum:

enum CpuFeatures {
    CPU_MMX             = 1
};

from https://github.com/opencv/opencv/blob/master/modules/core/include/opencv2/core/cvdef.h#L161

with the error:

ERROR: LoadError: Unknown EnumConstantDecl type: CLType (Clang.cindex.Enum) cursor: CLCursor (Clang.cindex.EnumConstantDecl) CPU_MMX
Stacktrace:
[1] value(::Clang.cindex.EnumConstantDecl) at /Users/jsa/.julia/v0.6/Clang/src/cindex.jl:162

@Gnimuc Gnimuc mentioned this issue Mar 30, 2019
10 tasks
@Gnimuc Gnimuc added the c++ label Mar 30, 2019
@Gnimuc
Copy link
Member

Gnimuc commented Jul 28, 2022

Now you can use https://github.com/grasph/wrapit.

@Gnimuc Gnimuc closed this as completed Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants