fuzzybinary / dart_shared_library

An attempt to package Dart into a usable shared library (.dll / .so)
Other
77 stars 10 forks source link

NoSuchMethodError: No top-level method 'simplePrint' declared. #1

Closed arcticfox1919 closed 1 year ago

arcticfox1919 commented 1 year ago

Hi, I ran your example but got an error, can you see what could be the reason?

G:\Repository\git_code\c++\dart_shared_libray\.build\win64_vs2019\bin>simple_example.exe
Initializig Dart ----
Dart initialized, error was: null
Created isolate main
* 8373a Setting working directory: G:\Repository\git_code\c++\dart_shared_libray\.build\win64_vs2019\bin
The Dart VM service is listening on http://127.0.0.1:5858/
* 8373a Working directory URI: file:///G:/Repository/git_code/c++/dart_shared_libray/.build/win64_vs2019/bin/
* 286f Setting working directory: G:\Repository\git_code\c++\dart_shared_libray\.build\win64_vs2019\bin
* 286f Working directory URI: file:///G:/Repository/git_code/c++/dart_shared_libray/.build/win64_vs2019/bin/
Failed to invoke main: Unhandled exception:
NoSuchMethodError: No top-level method 'simplePrint' declared.
Receiver: top-level
Tried calling: simplePrint()
#0      NoSuchMethodError._throwNew (dart:core-patch/errors_patch.dart:191:5)
#1      simplePrint (file:///G:/Repository/git_code/c++/dart_shared_libray/.build/win64_vs2019/bin/hello_world.dart)
#2      main (file:///G:/Repository/git_code/c++/dart_shared_libray/.build/win64_vs2019/bin/hello_world.dart:4:3)
#3      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:297:19)
#4      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:192:26)

The Dart version I compiled is:

Dart SDK version: 3.0.0-edge.0c05e33836662da52b963158ccd6b9c211208429 (be) (Sat Feb 18 12:37:40 2023 +0000) on "windows_x64"
fuzzybinary commented 1 year ago

Good question. I haven't tried with Dart 3 yet, I wonder if something changed, I'll take a look.

fuzzybinary commented 1 year ago

Looks like it's actually a change in 2.19. I'm looking into what changed and see if I can have a workaround.

Thanks for letting me know!

fuzzybinary commented 1 year ago

@arcticfox1919 I've updated the code to work with 2.19+ and tested against tags/2.19.5. This is due to eliminating the native keyword (see the ticket mentioned above.)

arcticfox1919 commented 1 year ago

@fuzzybinary Thank you very much for your reply!