Giter Club home page Giter Club logo

Comments (2)

jschwe avatar jschwe commented on July 2, 2024

I've read that this is possible to have multiple cxx rlib, one rust static library that does extern crate thingy.

Until the rlib format is stabilized for external linker consumption, you do need to ensure that only one rust static library is linked into a C/C++ executable. Adding a dummy crate that depends on the crates you are interested in would be a solution and could be automated by generating a corresponding Cargo.toml.

As for running cxxbridge: I don't work with C++ myself, but in principle all you need to do is run the cxxbridge command once for every file that needs cxx bindings. A nice solution might be to parse the cargo metadata output of the staticlib crate, and run cxxbridge on every dependency that depends directly on cxx (My assumption is that you only depend on cxx directly when you want bindings for that crate). There is already some parsing of cargo metadata implemented, to determine the version of cxxbridge to use.

For a first test, this dependency parsing could be skipped entirely and just pass the relevant .rs file manually via the FILES parameter. The corrosion_add_cxxbridge function needs to be adapted slightly for this to allow absolute paths, and still place the generated files into sensible directories, but I think the cxxbridge itself doesn't really need to know about the crate name or anything.

Then you have a bunch of .cc and .h files, and if there are no duplicate symbol names, just linking the generated cxx static lib with the rust static lib into your C++ project should hopefully work.

from corrosion.

OlivierLDff avatar OlivierLDff commented on July 2, 2024

Ok I see, some hours of exploration/experiment are still needed. I'm still new to rust so I'm not that fluent in all of the ecosystem.
I think I will go the simple way of linking to dynamic libraries which should solve the issues right?

from corrosion.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.