Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to load .so libary on linux desktop #8

Closed
LordCommanderMay opened this issue Jul 18, 2022 · 10 comments
Closed

Fails to load .so libary on linux desktop #8

LordCommanderMay opened this issue Jul 18, 2022 · 10 comments

Comments

@LordCommanderMay
Copy link

LordCommanderMay commented Jul 18, 2022

Launching lib/main.dart on Linux in debug mode...
Building Linux application...
Debug service listening on ws://127.0.0.1:37089/w-K6VIMgRmg=/ws
Syncing files to device Linux...
[ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: Exception: Could not load any zeromq library
#0      ZContext._initBindings (package:dartzmq/src/zeromq.dart:77:7)
#1      new ZContext (package:dartzmq/src/zeromq.dart:66:5)
#2      main (package:remote_volume_control/main.dart:6:28)
#3      _runMainZoned.<anonymous closure>.<anonymous closure> (dart:ui/hooks.dart:130:25)
#4      _rootRun (dart:async/zone.dart:1426:13)
#5      _CustomZone.run (dart:async/zone.dart:1328:19)
#6      _runZoned (dart:async/zone.dart:1861:10)
#7      runZonedGuarded (dart:async/zone.dart:1849:12)
#8      _runMainZoned.<anonymous closure> (dart:ui/hooks.dart:126:5)
#9      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:297:19)
#10     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)

[dartzmq] Failed to load library zmq:  Invalid argument(s): Failed to lookup symbol 'zmq_poller_new': /lib64/libzmq.so: undefined symbol: zmq_poller_new
[dartzmq] Failed to load library libzmq:  Invalid argument(s): Failed to load dynamic library 'liblibzmq.so': liblibzmq.so: cannot open shared object file: No such file or directory
[dartzmq] Failed to load library libzmq-v142-mt-4_3_5:  Invalid argument(s): Failed to load dynamic library 'liblibzmq-v142-mt-4_3_5.so': liblibzmq-v142-mt-4_3_5.so: cannot open shared object file: No such file or directory

--------------------------------------------------

sean@sean-fedora /lib64> ls | grep libzmq
libzmq.so
libzmq.so.5
libzmq.so.5.2.4

not entirely sure whats going on here the code is looking in the right place. any help would be appreciated

@enwi
Copy link
Owner

enwi commented Jul 19, 2022

You need to either get a precompiled libzmq.so library or compile it youself and copy it into the build folder

@LordCommanderMay
Copy link
Author

@enwi thanks for the quick response!
I tried using the .so file from zmq fedora package and placed it next to the executable and the lib folder above it where I found another .so file for whatever reason running the 'flutter run' command deletes the so file in those locations. I also tried putting in just the build folder as you said. it does not delete it but still gives me the same error. I will next attempt to compile zmq myself but if you could be more specific about where .so library should go that would be very helpful thanks.
Screenshot from 2022-07-19 12-45-23

@enwi
Copy link
Owner

enwi commented Jul 19, 2022

I don't know the exact place for linux, but for windows it goes here build\windows\runner\Debug\. and build\windows\runner\Release\.. Is the build output structure similar on linux?

@enwi
Copy link
Owner

enwi commented Jul 19, 2022

I remember that @ach-ee added some instructions for Linux, maybe these help:

Linux

Installing libzmq and running dart pub add dartzmq should be all that is required to use this package in your own application. To also run the example project, follow these steps:

  1. Install libzmq
  2. Install flutter (It may be easiest to install from source, otherwise you can follow the snap instructions)
  3. Update .profile with PATH to /flutter/bin (e.g. export PATH=$PATH:~/src/flutter/bin)
  4. Ensure ninja-build, clang, and libgtk-3-dev are installed (via apt or other package manager)
  5. Run flutter
  6. Run flutter config --enable-linux-desktop
  7. Clone this repo and cd dartzmq/example
  8. flutter create . to enable linux desktop for this project
  9. flutter run
  10. Click the "Send" button and the received message will be displayed as an array of ints [1,2,3,4,5]

@LordCommanderMay
Copy link
Author

No luck with either of your suggestions unfortunately.

DynamicLibrary _dlOpenPlatformSpecific(final String name,
    {final String? path}) {
  String fullPath = _platformPath(name, path: path);
  return DynamicLibrary.open('/usr/local/lib/libzmq.so');
}

I replaced with the fullPath variable with the actual full path and I am getting a slightly different error.

[ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: Exception: Could not load any zeromq library
#0      ZContext._initBindings (package:dartzmq/src/zeromq.dart:77:7)
#1      new ZContext (package:dartzmq/src/zeromq.dart:66:5)
#2      main (package:remote_volume_control/main.dart:6:28)
#3      _runMainZoned.<anonymous closure>.<anonymous closure> (dart:ui/hooks.dart:130:25)
#4      _rootRun (dart:async/zone.dart:1426:13)
#5      _CustomZone.run (dart:async/zone.dart:1328:19)
#6      _runZoned (dart:async/zone.dart:1861:10)
#7      runZonedGuarded (dart:async/zone.dart:1849:12)
#8      _runMainZoned.<anonymous closure> (dart:ui/hooks.dart:126:5)
#9      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:297:19)
#10     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)

[dartzmq] Failed to load library zmq:  Invalid argument(s): Failed to lookup symbol 'zmq_poller_new': /usr/local/lib/libzmq.so: undefined symbol: zmq_poller_new
[dartzmq] Failed to load library libzmq:  Invalid argument(s): Failed to lookup symbol 'zmq_poller_new': /usr/local/lib/libzmq.so: undefined symbol: zmq_poller_new
[dartzmq] Failed to load library libzmq-v142-mt-4_3_5:  Invalid argument(s): Failed to lookup symbol 'zmq_poller_new': /usr/local/lib/libzmq.so: undefined symbol: zmq_poller_new

any ideas? this .so was complied from the source code with cmake.

@LordCommanderMay
Copy link
Author

LordCommanderMay commented Jul 19, 2022

sean@sean-fedora /u/l/lib> nm -D libzmq.so.5.2.5 | grep poll
                 U epoll_create1@GLIBC_2.9
                 U epoll_ctl@GLIBC_2.3.2
                 U epoll_wait@GLIBC_2.3.2
                 U poll@GLIBC_2.2.5
0000000000072010 T zmq_poll

zmq_poller_new is not exported on the Linux library

@enwi
Copy link
Owner

enwi commented Jul 19, 2022

Then it can load the library, just that the version does not have support for zmq_poller

@LordCommanderMay
Copy link
Author

sorry I ran the command wrong..

sean@sean-fedora /u/l/lib> nm libzmq.so.5.2.5 | grep zmq_poller_new
0000000000072df0 t _Z14zmq_poller_newv
0000000000019a9c t _Z14zmq_poller_newv.cold

I am a bit of a noob when it comes to c-shared Libraries. maybe the linux x86 exports it differently? I have no idea.

@LordCommanderMay
Copy link
Author

LordCommanderMay commented Jul 19, 2022

After some research this seems to be more of a problem with how fedora/cmake version of zmq is complied so I'll close this

@LordCommanderMay
Copy link
Author

Then it can load the library, just that the version does not have support for zmq_poller

Yes your right i remove all poller related variable and functions and it works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants