Praxa-Sense / dartedflib

Wrapper for EDFlib
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

Failed to load dynamic library 'libedflib.so': dlopen failed: library "libedflib.so" not found #2

Open SungchangChoi opened 1 year ago

SungchangChoi commented 1 year ago

I would like to generate a file in EDF format. So I processed steps below.

  1. Download EDFLIb v1.23 and unzipped contents in C:\edflib\
  2. add PATH system vaialbe with C:\edflib and create EDFLIB_PATH variable with C:\edflib
  3. installed Visual Studio 2022
  4. installed LLVM and add PATH system variable with C:\program files\LLVM\bin
  5. installed gcc
  6. complied EDFLib with two command as you mentioned in Readme. so I got files edflib.dll and libedflib.so in C:\edflib
    • gcc -Wall -Wextra -Wshadow -Wformat-nonliteral -Wformat-security -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -shared edflib.c -o edflib.dll
    • gcc -Wall -Wextra -Wshadow -Wformat-nonliteral -Wformat-security -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -shared edflib.c -o libedflib.so
      1. add "dartedflib: ^0.1.0" in pubspec.yaml like other packages
      2. add "import 'package:dartedflib/dartedflib.dart';" on top of the file which calls EdfWriter( ) command

I runned my project and click the button that calls EdfWriter( ) method, then I got this message.

E/flutter ( 7439): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Invalid argument(s): Failed to load dynamic library 'libedflib.so': dlopen failed: library "libedflib.so" not found E/flutter ( 7439): #0 _open (dart:ffi-patch/ffi_dynamic_library_patch.dart:11:43) E/flutter ( 7439): #1 new DynamicLibrary.open (dart:ffi-patch/ffi_dynamic_library_patch.dart:22:12) E/flutter ( 7439): #2 dylib (package:dartedflib/src/dylib.dart:8:47) E/flutter ( 7439): #3 new EdfWriter (package:dartedflib/src/edf_writer.dart:82:15) E/flutter ( 7439): #4 saveMeasureData (package:fitsig_pro/F7_UI/P20_MEASURE/df_measure.dart:413:18)

flutter doctor said, PS D:\WORK\FITSIG\CODE\FT\fitsig_pro> flutter doctor Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel master, 3.9.0-7.0.pre.32, on Microsoft Windows [Version 10.0.19045.2965], locale ko-KR) [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 33.0.2) [√] Android Studio (version 2022.1) [√] VS Code (version 1.78.2) [√] Connected device (1 available) [√] Network resources

• No issues found!

I don't know what i have to do. Is there additional job i have to do? Thanks you commets in advance~ : )

praxamarnix commented 1 year ago

One thing that I might not have explained correctly in the readme is the way you have to tell dart where it can find your compiled dartedflib. Depending on how you start the program you can do the following:

  1. When you want to run the program directly from visual studio code, it is best to set EDFLIB_PATH as an environment variable. For example, in your launch.json, or in your workspace file.

    I have set it in my workspace file like so:

    "settings": {
        "dart.env": {
            "EDFLIB_PATH": "third_party/edflib/linux/libedflib.so",
        },
    },
  2. When you have created an executable of your application, the file dartedflib.so is best to locate next to your executable. There are some other paths where it will search, and that depends on the implementation of dylib.

See https://github.com/Praxa-Sense/dartedflib/blob/main/lib/src/dylib.dart for how dylib is called. See https://github.com/ubuntu-flutter-community/dylib.dart/blob/main/lib/dylib.dart for more info on how it is resolved.

I hope this answers your question. Good luck with setting up the library!

praxamarnix commented 1 year ago

I've been re-reading your question and I see that you have put the path in the correct place. What kind of flutter project are you making, since you try to run it over a VM? Is it a windows or a linux project?

SungchangChoi commented 1 year ago

I've been re-reading your question and I see that you have put the path in the correct place. What kind of flutter project are you making, since you try to run it over a VM? Is it a windows or a linux project?

My flutter project is targeting iOS and Android. I am using Android Stuido on Windows 10 . Above Exception was thrown when run the main dart file as debug mode for Android (API 32) device

I think this is happen since my short of knowledge and experience for ffi and dylib. T^T I need more study.
Thanks for your kind answer~~~~

praxamarnix commented 1 year ago

I have only tested this library on windows, linux and macOS. The company I made this library for is not interested in an Android version.