surrealdb / surrealdb

A scalable, distributed, collaborative, document-graph database, for the realtime web
https://surrealdb.com
Other
26.83k stars 859 forks source link

Bug: Flutter app with embedded Rust failing to compile as a result of SurrealDB dependency usage #3986

Closed cabaucom376 closed 4 months ago

cabaucom376 commented 4 months ago

Describe the bug

A Flutter app using flutter_rust_bridge, intended to help compile an embedded SurrealDB rust backend, is failing to build as a result of the usage of the SurrealDB dependency. Following the embedding in rust docs the provided example results in the compilation of the application to blow up with various "Undefined symbol" errors reported. I began removing each piece of code one by one until the app would compile, and it would only do so unless the use surrealdb::engine::local::Mem; use surrealdb::sql::Thing; use surrealdb::Surreal; imports and associated code was removed. I am attempting to track down wether this is an issue within the SurrealDB or flutter_rust_bridge side of things.

Steps to reproduce

  1. Initiate flutter_rust_bridge project
  2. Install SurrealDB dependency within the rust lib
  3. Copy embedding in rust docs example
  4. flutter_rust_bridge_codegen generate within flutter project to generate bindings
  5. Attempt to run/build application

Expected behaviour

Flutter application to compile and run with the Rust backend using SurrealDB.

SurrealDB version

surrealdb = { version = "1.4.2", features = ["kv-mem", "kv-rocksdb"] }

Contact Details

admin@novoid.co

Is there an existing issue for this?

Code of Conduct

cabaucom376 commented 4 months ago

Console output while compiling for reference:

Details

```bash Launching lib/main_dev.dart on iPhone 15 Pro in debug mode... Xcode build done. 30.9s Failed to build iOS app Error (Xcode): Undefined symbol: std::__1::basic_string, std::__1::allocator>::at(unsigned long) const Error (Xcode): Undefined symbol: std::__1::basic_string, std::__1::allocator>::find(char, unsigned long) const Error (Xcode): Undefined symbol: std::__1::basic_string, std::__1::allocator>::rfind(char, unsigned long) const Error (Xcode): Undefined symbol: std::__1::basic_string, std::__1::allocator>::compare(unsigned long, unsigned long, char const*) const Error (Xcode): Undefined symbol: std::__1::basic_string, std::__1::allocator>::compare(unsigned long, unsigned long, char const*, unsigned long) const Error (Xcode): Undefined symbol: std::__1::__shared_weak_count::__get_deleter(std::type_info const&) const Error (Xcode): Undefined symbol: std::__1::locale::has_facet(std::__1::locale::id&) const Error (Xcode): Undefined symbol: std::__1::locale::use_facet(std::__1::locale::id&) const Error (Xcode): Undefined symbol: std::__1::ios_base::getloc() const Error (Xcode): Undefined symbol: std::exception::what() const Error (Xcode): Undefined symbol: std::logic_error::logic_error(char const*) Error (Xcode): Undefined symbol: std::logic_error::logic_error(std::__1::basic_string, std::__1::allocator> const&) Error (Xcode): Undefined symbol: std::logic_error::logic_error(std::logic_error const&) Error (Xcode): Undefined symbol: std::length_error::~length_error() Error (Xcode): Undefined symbol: std::out_of_range::~out_of_range() Error (Xcode): Undefined symbol: std::exception_ptr::exception_ptr(std::exception_ptr const&) Error (Xcode): Undefined symbol: std::exception_ptr::~exception_ptr() Error (Xcode): Undefined symbol: std::runtime_error::runtime_error(char const*) Error (Xcode): Undefined symbol: std::runtime_error::runtime_error(std::__1::basic_string, std::__1::allocator> const&) Error (Xcode): Undefined symbol: std::runtime_error::~runtime_error() Error (Xcode): Undefined symbol: std::invalid_argument::~invalid_argument() Error (Xcode): Undefined symbol: std::bad_optional_access::~bad_optional_access() Error (Xcode): Undefined symbol: std::bad_array_new_length::bad_array_new_length() Error (Xcode): Undefined symbol: std::bad_array_new_length::~bad_array_new_length() Error (Xcode): Undefined symbol: std::__1::__call_once(unsigned long volatile&, void*, void (*)(void*)) Error (Xcode): Undefined symbol: std::__1::__get_sp_mut(void const*) Error (Xcode): Undefined symbol: std::__1::__next_prime(unsigned long) Error (Xcode): Undefined symbol: std::__1::bad_weak_ptr::~bad_weak_ptr() Error (Xcode): Undefined symbol: std::__1::basic_string, std::__1::allocator>::at(unsigned long) Error (Xcode): Undefined symbol: std::__1::basic_string, std::__1::allocator>::erase(unsigned long, unsigned long) Error (Xcode): Undefined symbol: std::__1::basic_string, std::__1::allocator>::__init(char const*, unsigned long) Error (Xcode): Undefined symbol: std::__1::basic_string, std::__1::allocator>::__init(unsigned long, char) Error (Xcode): Undefined symbol: std::__1::basic_string, std::__1::allocator>::append(char const*) Error (Xcode): Undefined symbol: std::__1::basic_string, std::__1::allocator>::append(char const*, unsigned long) Error (Xcode): Undefined symbol: std::__1::basic_string, std::__1::allocator>::append(std::__1::basic_string, std::__1::allocator> const&, unsigned long, unsigned long) Error (Xcode): Undefined symbol: std::__1::basic_string, std::__1::allocator>::append(unsigned long, char) Error (Xcode): Undefined symbol: std::__1::basic_string, std::__1::allocator>::assign(char const*) Error (Xcode): Undefined symbol: std::__1::basic_string, std::__1::allocator>::assign(char const*, unsigned long) Error (Xcode): Undefined symbol: std::__1::basic_string, std::__1::allocator>::assign(unsigned long, char) Error (Xcode): Undefined symbol: std::__1::basic_string, std::__1::allocator>::insert(unsigned long, char const*) Error (Xcode): Undefined symbol: std::__1::basic_string, std::__1::allocator>::insert(unsigned long, char const*, unsigned long) Error (Xcode): Undefined symbol: std::__1::basic_string, std::__1::allocator>::resize(unsigned long, char) Error (Xcode): Undefined symbol: std::__1::basic_string, std::__1::allocator>::replace(unsigned long, unsigned long, char const*, unsigned long) Error (Xcode): Undefined symbol: std::__1::basic_string, std::__1::allocator>::reserve(unsigned long) Error (Xcode): Undefined symbol: std::__1::basic_string, std::__1::allocator>::push_back(char) Error (Xcode): Undefined symbol: std::__1::basic_string, std::__1::allocator>::basic_string(std::__1::basic_string, std::__1::allocator> const&) Error (Xcode): Undefined symbol: std::__1::basic_string, std::__1::allocator>::basic_string(std::__1::basic_string, std::__1::allocator> const&, unsigned long, unsigned long, std::__1::allocator const&) Error (Xcode): Undefined symbol: std::__1::basic_string, std::__1::allocator>::~basic_string() Error (Xcode): Undefined symbol: std::__1::basic_string, std::__1::allocator>::operator=(std::__1::basic_string, std::__1::allocator> const&) Error (Xcode): Undefined symbol: std::__1::future_error::future_error(std::__1::error_code) Error (Xcode): Undefined symbol: std::__1::future_error::~future_error() Error (Xcode): Undefined symbol: std::__1::placeholders::_1 Error (Xcode): Undefined symbol: std::__1::placeholders::_2 Error (Xcode): Undefined symbol: std::__1::basic_istream>::sentry::sentry(std::__1::basic_istream>&, bool) Error (Xcode): Undefined symbol: std::__1::basic_istream>::~basic_istream() Error (Xcode): Undefined symbol: std::__1::basic_ostream>::put(char) Error (Xcode): Undefined symbol: std::__1::basic_ostream>::flush() Error (Xcode): Undefined symbol: std::__1::basic_ostream>::sentry::sentry(std::__1::basic_ostream>&) Error (Xcode): Undefined symbol: std::__1::basic_ostream>::sentry::~sentry() Error (Xcode): Undefined symbol: std::__1::basic_ostream>::~basic_ostream() Error (Xcode): Undefined symbol: std::__1::basic_ostream>::operator<<(void const*) Error (Xcode): Undefined symbol: std::__1::basic_ostream>::operator<<(bool) Error (Xcode): Undefined symbol: std::__1::basic_ostream>::operator<<(double) Error (Xcode): Undefined symbol: std::__1::basic_ostream>::operator<<(float) Error (Xcode): Undefined symbol: std::__1::basic_ostream>::operator<<(int) Error (Xcode): Undefined symbol: std::__1::basic_ostream>::operator<<(unsigned int) Error (Xcode): Undefined symbol: std::__1::basic_ostream>::operator<<(unsigned long) Error (Xcode): Undefined symbol: std::__1::basic_ostream>::operator<<(long long) Error (Xcode): Undefined symbol: std::__1::basic_ostream>::operator<<(unsigned long long) Error (Xcode): Undefined symbol: std::__1::random_device::random_device(std::__1::basic_string, std::__1::allocator> const&) Error (Xcode): Undefined symbol: std::__1::random_device::~random_device() Error (Xcode): Undefined symbol: std::__1::random_device::operator()() Error (Xcode): Undefined symbol: std::__1::__shared_count::~__shared_count() Error (Xcode): Undefined symbol: std::__1::basic_iostream>::~basic_iostream() Error (Xcode): Undefined symbol: std::__1::__thread_struct::__thread_struct() Error (Xcode): Undefined symbol: std::__1::__thread_struct::~__thread_struct() Error (Xcode): Undefined symbol: std::__1::basic_streambuf>::sync() Error (Xcode): Undefined symbol: std::__1::basic_streambuf>::imbue(std::__1::locale const&) Error (Xcode): Undefined symbol: std::__1::basic_streambuf>::uflow() Error (Xcode): Undefined symbol: std::__1::basic_streambuf>::setbuf(char*, long) Error (Xcode): Undefined symbol: std::__1::basic_streambuf>::xsgetn(char*, long) Error (Xcode): Undefined symbol: std::__1::basic_streambuf>::xsputn(char const*, long) Error (Xcode): Undefined symbol: std::__1::basic_streambuf>::showmanyc() Error (Xcode): Undefined symbol: std::__1::basic_streambuf>::basic_streambuf() Error (Xcode): Undefined symbol: std::__1::basic_streambuf>::~basic_streambuf() Error (Xcode): Undefined symbol: std::__1::future_category() Error (Xcode): Undefined symbol: std::__1::__assoc_sub_state::__sub_wait(std::__1::unique_lock&) Error (Xcode): Undefined symbol: std::__1::__assoc_sub_state::set_exception(std::exception_ptr) Error (Xcode): Undefined symbol: std::__1::__assoc_sub_state::wait() Error (Xcode): Undefined symbol: std::__1::__assoc_sub_state::__execute() Error (Xcode): Undefined symbol: std::__1::condition_variable::notify_all() Error (Xcode): Undefined symbol: std::__1::condition_variable::notify_one() Error (Xcode): Undefined symbol: std::__1::condition_variable::__do_timed_wait(std::__1::unique_lock&, std::__1::chrono::time_point>>) Error (Xcode): Undefined symbol: std::__1::condition_variable::wait(std::__1::unique_lock&) Error (Xcode): Linker command failed with exit code 1 (use -v to see invocation) Could not build the application for the simulator. Error launching application on iPhone 15 Pro. Exited (1). ```

xuxiaocheng0201 commented 2 weeks ago

@cabaucom376 Hello, I have encountered a similar problem. Can you tell me how it was resolved?

cabaucom376 commented 2 weeks ago

@xuxiaocheng0201 I ended up finding out that it was issue with RocksDB compiling. I've got around that by using the SurrealKV embedded storage method instead and that compiles in Flutter perfectly with flutter_rust_bridge. If you have any more questions feel free to DM me on Discord @ aquanaga

xuxiaocheng0201 commented 2 weeks ago

Thanks for your reply! The author of flutter_rust_bridge answered just now. https://github.com/fzyzcjy/flutter_rust_bridge/issues/2267#issuecomment-2322922732