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

StdVector of pointer with CxxWrap 0.15 #419

Closed
grasph opened this issue Mar 22, 2024 · 0 comments · Fixed by JuliaInterop/libcxxwrap-julia#148
Closed

StdVector of pointer with CxxWrap 0.15 #419

grasph opened this issue Mar 22, 2024 · 0 comments · Fixed by JuliaInterop/libcxxwrap-julia#148

Comments

@grasph
Copy link

grasph commented Mar 22, 2024

Hello @barche , hello @melven ,

I have troubles with CxxWrap v0.15 and STL vectors of pointers. I get the following error message when compiling the wrapper.

                 from tmp.cc:1:
/home/pgras/.julia/artifacts/33ec05e328daf2b9f2b25f421ea33a5d78189cf2/include/jlcxx/module.hpp: In instantiation of ‘jlcxx::detail::ReturnTypeAdapter<R, Args>::return_type jlcxx::detail::ReturnTypeAdapter<R, Args>::operator()(const void*, jlcxx::static_julia_type<Args>...) [with R = A* const; Args = {std::queue<A*, std::deque<A*, std::allocator<A*> > >&}; return_type = A*]’:
/home/pgras/.julia/artifacts/33ec05e328daf2b9f2b25f421ea33a5d78189cf2/include/jlcxx/module.hpp:73:45:   required from ‘static jlcxx::detail::CallFunctor<R, Args>::return_type jlcxx::detail::CallFunctor<R, Args>::apply(const void*, jlcxx::static_julia_type<Args>...) [with R = A* const; Args = {std::queue<A*, std::deque<A*, std::allocator<A*> > >&}; return_type = A*]’
/home/pgras/.julia/artifacts/33ec05e328daf2b9f2b25f421ea33a5d78189cf2/include/jlcxx/module.hpp:252:12:   required from ‘void* jlcxx::FunctionWrapper<R, Args>::pointer() [with R = A* const; Args = {std::queue<A*, std::deque<A*, std::allocator<A*> > >&}]’
/home/pgras/.julia/artifacts/33ec05e328daf2b9f2b25f421ea33a5d78189cf2/include/jlcxx/module.hpp:250:17:   required from here
/home/pgras/.julia/artifacts/33ec05e328daf2b9f2b25f421ea33a5d78189cf2/include/jlcxx/module.hpp:48:28: error: cannot convert ‘jlcxx::WrappedCppPtr’ to ‘jlcxx::detail::ReturnTypeAdapter<A* const, std::queue<A*, std::deque<A*, std::allocator<A*> > >&>::return_type’ {aka ‘A*’} in return
   48 |     return convert_to_julia((*std_func)(convert_to_cpp<Args>(args)...));
      |            ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                            |
      |                            jlcxx::WrappedCppPtr

The code producing this error is the following:

#include "jlcxx/jlcxx.hpp"
#include "jlcxx/stl.hpp"

struct A{
};

std::vector<A*> f(){ static A a; return std::vector({&a}); }

namespace jlcxx {
  template<> struct IsMirroredType<A> : std::false_type { };
}

JLCXX_MODULE define_julia_module(jlcxx::Module& module){
  auto t =  module.add_type<A>("A");
  module.method("f", f);
}

Julia script to compile and use the library in one shot:

import CxxWrap

open("tmp.cc", "w") do f
    write(f,
"""#include "jlcxx/jlcxx.hpp"
#include "jlcxx/functions.hpp"
#include "jlcxx/stl.hpp"

struct A{
};

std::vector<A*> f(){ static A a; return std::vector({&a}); }

namespace jlcxx {
  template<> struct IsMirroredType<A> : std::false_type { };
}

JLCXX_MODULE define_julia_module(jlcxx::Module& module){
  auto t =  module.add_type<A>("A");
  module.method("f", f);
}
""")
end

julia_base=dirname(Sys.BINDIR)
cxxwrap_base = CxxWrap.prefix_path()

run(`g++ -fPIC -shared -o libMyTest.so -I$(julia_base)/include/julia -I$(cxxwrap_base)/include tmp.cc  -L$(cxxwrap_base)/lib`)

module MyTest

using CxxWrap
@wrapmodule(()->"./libMyTest.so")

function __init__()
    @initcxx
end

end #module

import .MyTest
println(typeof(MyTest.f()))

It works fine with CxxWrap 0.14.2 + libcxxwarp v0.11.2+1 and it gives above error with CxxWrap 0.15.0 + libcxxwrap v0.12.2+0

Philippe.

grasph added a commit to grasph/wrapit that referenced this issue Mar 23, 2024
Code for CxxWrap versions 0.15.x to generate differs from code for vesions
0.14.x, due to a change in the API. Wrapping of STL vectors of object pointers
do not work with version 0.15.0.  More details in
JuliaInterop/CxxWrap.jl#419. The unit tests and the
ROOT example that use such vector are conifgure to use 0.14.x version for now.

The CxxWrap version the code should be generated can be selected using the
new `cxxwrap_version` configuration parameter.

Several other changes:

  o new --get command line option to retrieve values of some parameters;

  o new --add-cfg command line option to configure parameter normally
    set in the .wit configuration file;

  o fixed generation of random uuid;

  o add check of the verions of the libcxxwrap when compiling and when running
  the code.

  o Cleanup Julia package dependencies installation and version handling;
    Removed project setting from runtests.jl which is not needed anymore, as
    each test runs within its own temporary Julia project.
grasph added a commit to grasph/wrapit that referenced this issue Mar 23, 2024
Code for CxxWrap versions 0.15.x to generate differs from code for vesions
0.14.x, due to a change in the API. Wrapping of STL vectors of object pointers
do not work with version 0.15.0.  More details in
JuliaInterop/CxxWrap.jl#419. The unit tests and the
ROOT example that use such vector are conifgure to use 0.14.x version for now.

The CxxWrap version the code should be generated can be selected using the
new `cxxwrap_version` configuration parameter.

Several other changes:

  o new --get command line option to retrieve values of some parameters;

  o new --add-cfg command line option to configure parameter normally
    set in the .wit configuration file;

  o fixed generation of random uuid;

  o add check of the verions of the libcxxwrap when compiling and when running
  the code.

  o Cleanup Julia package dependencies installation and version handling;
    Removed project setting from runtests.jl which is not needed anymore, as
    each test runs within its own temporary Julia project.
grasph added a commit to grasph/wrapit that referenced this issue Mar 23, 2024
Code for CxxWrap versions 0.15.x to generate differs from code for vesions
0.14.x, due to a change in the API. Wrapping of STL vectors of object pointers
do not work with version 0.15.0.  More details in
JuliaInterop/CxxWrap.jl#419. The unit tests and the
ROOT example that use such vector are conifgure to use 0.14.x version for now.

The CxxWrap version the code should be generated can be selected using the
new `cxxwrap_version` configuration parameter.

Several other changes:

  o new --get command line option to retrieve values of some parameters;

  o new --add-cfg command line option to configure parameter normally
    set in the .wit configuration file;

  o fixed generation of random uuid;

  o add check of the verions of the libcxxwrap when compiling and when running
  the code.

  o Cleanup Julia package dependencies installation and version handling;
    Removed project setting from runtests.jl which is not needed anymore, as
    each test runs within its own temporary Julia project.
grasph added a commit to grasph/wrapit that referenced this issue Mar 23, 2024
Code for CxxWrap versions 0.15.x to generate differs from code for vesions
0.14.x, due to a change in the API. Wrapping of STL vectors of object pointers
do not work with version 0.15.0.  More details in
JuliaInterop/CxxWrap.jl#419. The unit tests and the
ROOT example that use such vector are conifgure to use 0.14.x version for now.

The CxxWrap version the code should be generated can be selected using the
new `cxxwrap_version` configuration parameter.

Several other changes:

  o new --get command line option to retrieve values of some parameters;

  o new --add-cfg command line option to configure parameter normally
    set in the .wit configuration file;

  o fixed generation of random uuid;

  o add check of the verions of the libcxxwrap when compiling and when running
  the code.

  o Cleanup Julia package dependencies installation and version handling;
    Removed project setting from runtests.jl which is not needed anymore, as
    each test runs within its own temporary Julia project.
grasph added a commit to grasph/wrapit that referenced this issue Mar 23, 2024
Code for CxxWrap versions 0.15.x to generate differs from code for vesions
0.14.x, due to a change in the API. Wrapping of STL vectors of object pointers
do not work with version 0.15.0.  More details in
JuliaInterop/CxxWrap.jl#419. The unit tests and the
ROOT example that use such vector are conifgure to use 0.14.x version for now.

The CxxWrap version the code should be generated can be selected using the
new `cxxwrap_version` configuration parameter.

Several other changes:

  o new --get command line option to retrieve values of some parameters;

  o new --add-cfg command line option to configure parameter normally
    set in the .wit configuration file;

  o fixed generation of random uuid;

  o add check of the verions of the libcxxwrap when compiling and when running
  the code.

  o Cleanup Julia package dependencies installation and version handling;
    Removed project setting from runtests.jl which is not needed anymore, as
    each test runs within its own temporary Julia project.
grasph added a commit to grasph/wrapit that referenced this issue Mar 23, 2024
Code for CxxWrap versions 0.15.x to generate differs from code for vesions
0.14.x, due to a change in the API. Wrapping of STL vectors of object pointers
do not work with version 0.15.0.  More details in
JuliaInterop/CxxWrap.jl#419. The unit tests and the
ROOT example that use such vector are conifgure to use 0.14.x version for now.

The CxxWrap version the code should be generated can be selected using the
new `cxxwrap_version` configuration parameter.

Several other changes:

  o new --get command line option to retrieve values of some parameters;

  o new --add-cfg command line option to configure parameter normally
    set in the .wit configuration file;

  o fixed generation of random uuid;

  o add check of the verions of the libcxxwrap when compiling and when running
  the code.

  o Cleanup Julia package dependencies installation and version handling;
    Removed project setting from runtests.jl which is not needed anymore, as
    each test runs within its own temporary Julia project.
grasph added a commit to grasph/wrapit that referenced this issue Mar 23, 2024
Code for CxxWrap versions 0.15.x to generate differs from code for vesions
0.14.x, due to a change in the API. Wrapping of STL vectors of object pointers
do not work with version 0.15.0.  More details in
JuliaInterop/CxxWrap.jl#419. The unit tests and the
ROOT example that use such vector are conifgure to use 0.14.x version for now.

The CxxWrap version the code should be generated can be selected using the
new `cxxwrap_version` configuration parameter.

Several other changes:

  o new --get command line option to retrieve values of some parameters;

  o new --add-cfg command line option to configure parameter normally
    set in the .wit configuration file;

  o fixed generation of random uuid;

  o add check of the verions of the libcxxwrap when compiling and when running
  the code.

  o Cleanup Julia package dependencies installation and version handling;
    Removed project setting from runtests.jl which is not needed anymore, as
    each test runs within its own temporary Julia project.
barche added a commit to JuliaInterop/libcxxwrap-julia that referenced this issue Apr 1, 2024
barche added a commit to JuliaInterop/libcxxwrap-julia that referenced this issue Apr 14, 2024
* Fix for JuliaInterop/CxxWrap.jl#419

* Fall back to CxxWrap as package in CI

* Don't build JLL in CI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant