Current state of Cxx.jl?

question
#1

I’d like to inquire about the current state of Cxx.jl. I’m aware of #390, but not really understand when or how the issues will be resolved.
My goal is to implement a small interface for the Kinect sensor (primarily for myself) and our work is mostly done on Windows, so the other part of my question is about it. Was/is/will it be supported? Also will this change with the 1.1 release of Julia (as the LLVM version changes if I know right)?
I also know about CxxWrap.jl, but Cxx.jl looks easier to me. (I have only a little experience in C++, so it’s possible that this whole project is too hard for me, but I have the interest to learn more about it.)

0 Likes

#2

X-ref:

0 Likes

#3

Thank you! I missed that thread.

0 Likes

#4

Hi, are you still there?

I’m going to merge this PR, but before that, I need more volunteers to test it. It would be great if you could give some feedback. :slight_smile:

4 Likes

#5

Definitely, but it’ll take some time as I’m not really experienced with c++ or Cxx itself. (But I happily help!)

1 Like

#6

Installing the a package (pkg> add https://github.com/Gnimuc/Cxx.jl#BB2) went fine, and also using Cxx.
I tried the first and second examples from the Cxx README, and they were also fine. I got an error at the third one.
Then I tried: pkg> test Cxx which also errored. The whole session is below.

C:\Users\cstamas\Documents\GIT>mkdir cxxtest

C:\Users\cstamas\Documents\GIT>cd cxxtest

C:\Users\cstamas\Documents\GIT\cxxtest>julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.1.0 (2019-01-21)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

(v1.1) pkg> activate .

(cxxtest) pkg> add https://github.com/Gnimuc/Cxx.jl#BB2
  Updating registry at `C:\Users\cstamas\.julia\registries\General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
   Cloning git-repo `https://github.com/Gnimuc/Cxx.jl`
  Updating git-repo `https://github.com/Gnimuc/Cxx.jl`
 Resolving package versions...
  Updating `C:\Users\cstamas\Documents\GIT\cxxtest\Project.toml`
  [a0b5b9ef] + Cxx v0.2.0+ #BB2 (https://github.com/Gnimuc/Cxx.jl)
  Updating `C:\Users\cstamas\Documents\GIT\cxxtest\Manifest.toml`
  [b99e7846] + BinaryProvider v0.5.3
  [a0b5b9ef] + Cxx v0.2.0+ #BB2 (https://github.com/Gnimuc/Cxx.jl)
  [2a0f44e3] + Base64
  [ade2ca70] + Dates
  [8ba89e20] + Distributed
  [b77e0a4c] + InteractiveUtils
  [76f85450] + LibGit2
  [8f399da3] + Libdl
  [56ddb016] + Logging
  [d6f4376e] + Markdown
  [44cfe95a] + Pkg
  [de0858da] + Printf
  [3fa0cd96] + REPL
  [9a3f8284] + Random
  [ea8e919c] + SHA
  [9e88b42a] + Serialization
  [6462fe0b] + Sockets
  [8dfed614] + Test
  [cf7118a7] + UUIDs
  [4ec0a83e] + Unicode
  Building Cxx → `C:\Users\cstamas\.julia\packages\Cxx\cSkk4\deps\build.log`

julia> using Cxx
[ Info: Precompiling Cxx [a0b5b9ef-44b7-5148-a2d1-f6db19f3c3d2]

julia> cxx""" #include<iostream> """
true

julia> cxx"""
       void mycppfunction() {
       int z = 0;
       int y = 5;
       int x = 10;
       z = x*y + 2;
       std::cout << "The number is" << z << std::endl;
       }
       """
true

julia> julia_function() = @cxx mycppfunction()
julia_function (generic function with 1 method)

julia> julia_function()
The number is52

julia> jnum = 10
10

julia> cx
ERROR: UndefVarError: cx not defined

julia> cxx"""
                  void printme(int x) {
                                std::cout << x << std::endl;
                                           }
                                                  """
true

julia> @cxx printme(jnum)
10

julia> @cxx printme(100)
100

julia> cxx"""
                void printme(const char *name) {
                            // const char* => std::string
                                        std::string sname = name;
                                                    // print it out
                                                                std::cout << sname << std::endl;
                                                                         }
                                                                              """
true

julia> @cxx printme(pointer("John"))
LLVM ERROR: Program used external function '__gxx_personality_v0' which could not be resolved!

C:\Users\cstamas\Documents\GIT\cxxtest>julia --project
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.1.0 (2019-01-21)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

(cxxtest) pkg> test Cxx
   Testing Cxx
 Resolving package versions...
    Status `C:\Users\cstamas\AppData\Local\Temp\jl_2E46.tmp\Manifest.toml`
  [b99e7846] BinaryProvider v0.5.3
  [a0b5b9ef] Cxx v0.2.0+ #BB2 (https://github.com/Gnimuc/Cxx.jl)
  [2a0f44e3] Base64  [`@stdlib/Base64`]
  [ade2ca70] Dates  [`@stdlib/Dates`]
  [8ba89e20] Distributed  [`@stdlib/Distributed`]
  [b77e0a4c] InteractiveUtils  [`@stdlib/InteractiveUtils`]
  [76f85450] LibGit2  [`@stdlib/LibGit2`]
  [8f399da3] Libdl  [`@stdlib/Libdl`]
  [56ddb016] Logging  [`@stdlib/Logging`]
  [d6f4376e] Markdown  [`@stdlib/Markdown`]
  [44cfe95a] Pkg  [`@stdlib/Pkg`]
  [de0858da] Printf  [`@stdlib/Printf`]
  [3fa0cd96] REPL  [`@stdlib/REPL`]
  [9a3f8284] Random  [`@stdlib/Random`]
  [ea8e919c] SHA  [`@stdlib/SHA`]
  [9e88b42a] Serialization  [`@stdlib/Serialization`]
  [6462fe0b] Sockets  [`@stdlib/Sockets`]
  [8dfed614] Test  [`@stdlib/Test`]
  [cf7118a7] UUIDs  [`@stdlib/UUIDs`]
  [4ec0a83e] Unicode  [`@stdlib/Unicode`]

Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ACCESS_VIOLATION at 0x0 -- unknown function (ip: 0000000000000000)
in expression starting at C:\Users\cstamas\.julia\packages\Cxx\cSkk4\test\runtests.jl:7
unknown function (ip: FFFFFFFFFFFFFFFF)
CloneFunctionAndAdjust at C:\Users\cstamas\.julia\packages\Cxx\cSkk4\deps\usr\bin\libcxxffi.DLL (unknown line)
ReplaceFunctionForDecl at C:\Users\cstamas\.julia\packages\Cxx\cSkk4\deps\usr\bin\libcxxffi.DLL (unknown line)
#ReplaceFunctionForDecl#5 at C:\Users\cstamas\.julia\packages\Cxx\cSkk4\src\clangwrapper.jl:385 [inlined]
#ReplaceFunctionForDecl at .\none:0
unknown function (ip: 000000001F2C2CC8)
jl_fptr_trampoline at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:1864
jl_apply_generic at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:2219
do_call at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:323
eval_value at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:411
eval_stmt_value at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:362 [inlined]
eval_body at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:755
eval_body at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:689
eval_body at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:689
jl_interpret_toplevel_thunk_callback at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:885
unknown function (ip: FFFFFFFFFFFFFFFE)
unknown function (ip: 000000000608EA8F)
unknown function (ip: 00000000000000A3)
jl_toplevel_eval_flex at /home/Administrator/buildbot/worker/package_win64/build/src\toplevel.c:764
jl_parse_eval_all at /home/Administrator/buildbot/worker/package_win64/build/src\ast.c:883
jl_load at /home/Administrator/buildbot/worker/package_win64/build/src\toplevel.c:826 [inlined]
jl_load_ at /home/Administrator/buildbot/worker/package_win64/build/src\toplevel.c:833
include at .\boot.jl:326 [inlined]
include_relative at .\loading.jl:1038
include at .\sysimg.jl:29
jl_apply_generic at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:2219
include at .\client.jl:403
jl_fptr_trampoline at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:1864
jl_apply_generic at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:2219
do_call at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:323
eval_value at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:411
eval_stmt_value at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:362 [inlined]
eval_body at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:755
jl_interpret_toplevel_thunk_callback at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:885
unknown function (ip: FFFFFFFFFFFFFFFE)
unknown function (ip: 0000000005B106EF)
unknown function (ip: FFFFFFFFFFFFFFFF)
jl_toplevel_eval_flex at /home/Administrator/buildbot/worker/package_win64/build/src\toplevel.c:764
jl_toplevel_eval_flex at /home/Administrator/buildbot/worker/package_win64/build/src\toplevel.c:713
jl_toplevel_eval at /home/Administrator/buildbot/worker/package_win64/build/src\toplevel.c:773 [inlined]
jl_toplevel_eval_in at /home/Administrator/buildbot/worker/package_win64/build/src\toplevel.c:793
eval at .\boot.jl:328
jl_apply_generic at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:2219
exec_options at .\client.jl:243
_start at .\client.jl:436
jl_apply_generic at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:2219
jl_apply at /home/Administrator/buildbot/worker/package_win64/build/src\julia.h:1571 [inlined]
true_main at /home/Administrator/buildbot/worker/package_win64/build/ui\repl.c:96
wmain at /home/Administrator/buildbot/worker/package_win64/build/ui\repl.c:217
__tmainCRTStartup at /usr/src/debug/mingw64-x86_64-runtime-5.0.3-1/crt\crtexe.c:329
mainCRTStartup at /usr/src/debug/mingw64-x86_64-runtime-5.0.3-1/crt\crtexe.c:212
BaseThreadInitThunk at C:\WINDOWS\System32\KERNEL32.DLL (unknown line)
RtlUserThreadStart at C:\WINDOWS\SYSTEM32\ntdll.dll (unknown line)
Allocations: 16304048 (Pool: 16301277; Big: 2771); GC: 38
ERROR: Package Cxx errored during testing

julia> versioninfo()
Julia Version 1.1.0
Commit 80516ca202 (2019-01-21 21:24 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-3632QM CPU @ 2.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, ivybridge)

(cxxtest) pkg> st
    Status `C:\Users\cstamas\Documents\GIT\cxxtest\Project.toml`
  [a0b5b9ef] Cxx v0.2.0+ #BB2 (https://github.com/Gnimuc/Cxx.jl)

I’m happy to try anything else, just don’t know what.

2 Likes

#7

Those errors are expected since Windows support is still experimental for now. Thanks for the feedback! :wink:

1 Like

#8

I tested at work on a Linux server (Ubuntu 16.04.6). The installation went fine and also all the examples I tried (1 to 7). (Although at the fourth example the function returned immediately and didn’t wait for a key.) Testing the package was also succesful.

(cxxtest) pkg> test Cxx
   Testing Cxx
 Resolving package versions...
    Status `/tmp/tmpmOcWmI/Manifest.toml`
  [b99e7846] BinaryProvider v0.5.3
  [a0b5b9ef] Cxx v0.2.0+ #BB2 (https://github.com/Gnimuc/Cxx.jl)
  [2a0f44e3] Base64  [`@stdlib/Base64`]
  [ade2ca70] Dates  [`@stdlib/Dates`]
  [8ba89e20] Distributed  [`@stdlib/Distributed`]
  [b77e0a4c] InteractiveUtils  [`@stdlib/InteractiveUtils`]
  [76f85450] LibGit2  [`@stdlib/LibGit2`]
  [8f399da3] Libdl  [`@stdlib/Libdl`]
  [56ddb016] Logging  [`@stdlib/Logging`]
  [d6f4376e] Markdown  [`@stdlib/Markdown`]
  [44cfe95a] Pkg  [`@stdlib/Pkg`]
  [de0858da] Printf  [`@stdlib/Printf`]
  [3fa0cd96] REPL  [`@stdlib/REPL`]
  [9a3f8284] Random  [`@stdlib/Random`]
  [ea8e919c] SHA  [`@stdlib/SHA`]
  [9e88b42a] Serialization  [`@stdlib/Serialization`]
  [6462fe0b] Sockets  [`@stdlib/Sockets`]
  [8dfed614] Test  [`@stdlib/Test`]
  [cf7118a7] UUIDs  [`@stdlib/UUIDs`]
  [4ec0a83e] Unicode  [`@stdlib/Unicode`]
Test Summary:                   | Pass  Total
import without using Cxx (#316) |    2      2
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
1
2
3
4
5
6
7
8
9
10
Test Summary: | Pass  Total
StdString     |    3      3
Test Summary: | Pass  Total
StdVector     |   70     70
e = (class std::length_error &) {
}

Test Summary: | Pass  Total
Exceptions    |    2      2
   Testing Cxx tests passed

julia> versioninfo()
Julia Version 1.1.0
Commit 80516ca202 (2019-01-21 21:24 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU E5-2683 v4 @ 2.10GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, broadwell)

Should I try any other tests (or examples)?

0 Likes

#9

I’m really happy to see that this is now in the JuliaInterop github group, when did that happen? Hopefully that is an indication that it will be more realistic to actually merge PR’s in the near future.

1 Like

#10

Thanks for this work!

I can confirm that everything went well when I tested on my system (Debian testing) : installation, examples from the README, and test suite.

1 Like

#11

It’s working great for me in both Ubuntu 18.04 and MacOS!

2 Likes