Comments (1)
I was tinkering with this myself today. My workaround solution at the moment is to build the rust code as a static library. Here's my setup (crate name is sqlite_adaptor
).
// Cargo.toml
[lib]
crate-type = ["staticlib"]
This produces target/debug/sqlite_adaptor.a
The next step is to link this static library with the cxxbridge static library built by your build.rs
into a shared library:
// Makefile
debug: target/debug/libsqlite_adaptor.so
bridge = $(shell find target/debug/ -name libcppbridge.a)
target/debug/libsqlite_adaptor.so:
gcc -shared -Wl,--whole-archive target/debug/libsqlite_adaptor.a \
-Wl,--no-whole-archive $(bridge) \
-o target/debug/libsqlite_adaptor.so
This is pretty janky right now as I'm still hacking on it, but it produces a shared library with the symbols from Rust library and the needed bridge code in target/debug/libsqlite_adaptor.so
from cxx.
Related Issues (20)
- Writing tests with CXX code causes linker issues
- Nonlocal extern "Rust" types trick in #942 doesn't work with Boxed types
- Raw identifiers in methods in extern "C++" block leads to wrong C++ code generation
- cxx::bridge behind a feature HOT 1
- Proposal: Implement Panic-to-Exception Handling Mode on FFI Boundary (Seeking Feedback)
- Can't figure out proper shim for UniquePtr instead of returning global singleton
- Compilation Issue: Linking to std in no_std Environment
- Is it possible to mark a C++ type as `Trivial`? HOT 2
- Question: estimate workload to call functions from geogram HOT 1
- Returning `CxxString` from Rust to C++ HOT 2
- Extern C++ Enums HOT 5
- Advice/example on docs.rs strategy HOT 2
- Feature Request: Add support for nested Vector types HOT 1
- Building two CXX C++ bindings with the same symbols but in different namespaces. HOT 2
- Including bridge from another crate
- Error in configuring crates_universe when included as a Bazel module
- Error compiling `cxx.cc` on Windows HOT 1
- Proposal: implementing native C++ std::error_code
- Link failure when using CXX-backed function from another crate
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cxx.