I have included libavcodec.dylib in a Flutter project following the standard Flutter FFI instructions.
Calling DynamicLibrary.open('libavcodec.59.dylib') executes without issue, and returns a non-negative handle address, which (I think) indicates a successful load.
When I try to lookup any symbol, Flutter throws an error:
"[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Invalid argument(s): Failed to lookup symbol...".
When I call providesSymbol() with various symbol names, it always returns false.
Does anyone know why this might be happening? Are there additional steps needed to bootstrap such a library? how I can debug the root cause of the issue?
I think this is the root header file. This is the lib's documentation.
It looks like the names in the dylib don't quite match the names in the C code. When I lookup the symbols by the names in the dylib, they resolve as expected.
The tool that I used to figure this out was the following:
nm -gU mylib.dylib
Related
If I clean my Flutter project (Android Studio), double is fine. I must do a pub get to get all the classes I am using. After the pub get double is not a type anymore. A few doubles are all right but most are an undefined error.
The implication is that one of the libraries in the pub get is messing up the basic double type.
I hope to get some recommendations on how to figure out this problem.
Where are the libraries that pub get retrieves?
Are they simply files I can rename to avoid the pub get to figure out the offender?
Thanks for any help.
To fix some previous issue I added a line that altered double behavior a long time ago. Updating Flutter and Dart did not like the line and considered double invalid. Removing the line fixed the problem. I found the line by looking at all the errors, and fortunately, the line was included in the error list.
Of course, I now wish I could recall what issue the line was handling. Sometimes a good comment is a nice idea.
When refactoring my code and when executing build_runner, I received out of a sudden loads of errors alike
[SEVERE] injectable_generator:injectable_builder on lib/application/authorization/xxx data_sync/sync_data.dart (cached):
type 'UnspecifiedInvalidResult' is not a subtype of type 'LibraryElementResult' in type cast
As can be seen, they result from the injectable package.
In my case, I was receiving a similar error:
[SEVERE] injectable_generator:injectable_config_builder on lib/main/di/dependency_injection.dart (cached):
Stack Overflow
[SEVERE] Failed after 118ms
pub finished with exit code 1
I figured out my problem was ocurring because I had cyclic injections...meaning that I was injecting into my interceptor a class that had injected a Dio client inside itself...it was an obvious loop, so I had to delete the injected class.
I'm not sure this is relevant, but I posted an answer since there's no more information online about this error...
This is caused by blanks in the directory names. I had added xxx upfront to the names of directories yet to be refactored.
So changing xxx data_sync to xxx_data_sync fixed the issue. The fun part, I am refactoring towards clean architecture and used dirty folder names going forward...
I found this code in arena.dart in the ffi examples of flutter:
/// The last [Arena] in the zone.
factory Arena.current() {
return Zone.current[#_currentArena];
}
I am puzzled and could not find anything about the #_currentArena thing. What type of language construct is that, and how does it work? Trying to name anything (else) starting with # gives immediate errors; auto completion doesn't find it, and trying to go to its definition doesn't work either.
So this seems to be something extremely special, and extremely undocumented... leaving me extremely curious!
Link to source file in Flutter SDK Sqlite Example
As #pskink pointed out in his comment, this is part of the symbols.
A Symbol object represents an operator or identifier declared in a
Dart program. You might never need to use symbols, but they’re
invaluable for APIs that refer to identifiers by name, because
minification changes identifier names but not identifier symbols.
To get the symbol for an identifier, use a symbol literal, which is
just # followed by the identifier:
#radix
#bar
Symbol literals are compile-time constants.
I am getting a mysterious error from flutter.
type 'Receipt' is not a subtype of type 'Receipt' of 'receipt' where
Receipt is from
file://Users/arash/source/shoppers/lib/services/receipt.dart
Receipt is from
package:shoppers/services/receipt.dart
The thing is, both of those files are the same.
Use package:... imports instead of relative imports everywhere.
See also https://github.com/flutter/flutter/issues/9319
This is a Flutter specific issue because otherwise Dart canonicalizes relative and absolute imports and recognizes them as the same.
I am using 2 third party libraries in my iPad app. The source code for these libraries are not known to me.
These libraries have the functions with same name in both. So I am are getting "Apple Mach - O (id) error" because of the collision in function names. I cant change the function names within them, as source code is not known. On building the app the error are occurring.
The error states that:
ld: duplicate symbol _T_strcpy in /Users/Desktop/untitled
folder/Universal/lib/simulator/myLib.a(mem.o) and
/Users/Library/Developer/Xcode/DerivedData/iOS-aqpprpcivvjjadbsutqqmtjsoczk/Build/Intermediates/ios.build/Debug-iphonesimulator/myApp
iPad.build/Objects-normal/i386/pdcrypte2.o for architecture i386
collect2: ld returned 1 exit status Command
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-g++-4.2
failed with exit code 1
Can anybody share some suggestions??
You're pretty much screwed. The creators of the original libraries failed one of the most basic rules of library development: Prepend all your exported symbols with a library specific prefix, to avoid namespace collisions.
Your only way out is to wrap each and every function from each library with a wrapper that has a namespace prefixed name, statically link the library to the wrapper and strip all not exported symbols. Then use the wrapper libraries and symbol names.
Actually if the libraries are static you can fix this issue: How to deal with symbol collisions between statically linked libraries?