yushulx / flutter_barcode_sdk

Build barcode QR detection apps for Windows, Linux, macOS, Android, iOS and web.
https://pub.dev/packages/flutter_barcode_sdk
MIT License
47 stars 18 forks source link

Required help to integrate curl #32

Closed sleepingsaint closed 2 years ago

sleepingsaint commented 2 years ago

I came across your article of flutter bar code plugin for linux. Following your tutorial I wanted to integrate libcurl into my plugin. But I am facing lot of issues. Hope you could help.

My Directory structure: image I copied my libcurl.so from /usr/lib/x86_64-linux-gnu/libcurl.so and placed it in my lib folder.

My CMakeLists.txt file: image

Error I am getting: image

I also tried different combinations in the cmakeslists.txt file, but nothing seems to work

target_link_libraries(${PLUGIN_NAME} PRIVATE flutter)
target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::GTK)
target_link_libraries(${PLUGIN_NAME} PRIVATE "${PROJECT_SOURCE_DIR}/lib/libcurl.so")

set(battery_bundled_libraries
  "${PROJECT_SOURCE_DIR}/lib/"
  PARENT_SCOPE
)
target_link_libraries(${PLUGIN_NAME} PRIVATE flutter)
target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::GTK)
target_link_libraries(${PLUGIN_NAME} PRIVATE "${PROJECT_SOURCE_DIR}/lib/libcurl.so")

set(battery_bundled_libraries
  "${PROJECT_SOURCE_DIR}/lib/libcurl.so"
  PARENT_SCOPE
)
target_link_libraries(${PLUGIN_NAME} PRIVATE flutter)
target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::GTK)
target_link_libraries(${PLUGIN_NAME} PRIVATE "libcurl.so")

set(battery_bundled_libraries
  "${PROJECT_SOURCE_DIR}/lib/"
  PARENT_SCOPE
)
target_link_libraries(${PLUGIN_NAME} PRIVATE flutter)
target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::GTK)
target_link_libraries(${PLUGIN_NAME} PRIVATE curl)

set(battery_bundled_libraries
  "${PROJECT_SOURCE_DIR}/lib/"
  PARENT_SCOPE
)

Atleast if possible could you please point me to some resources, where I can learn more about configuring these libraries and understand how they work in a better way. Any help is appreciated. Thanks in advance :)

yushulx commented 2 years ago

@sleepingsaint it seems to be a cmake build issue. I suggest you can create a simple cmake project to test libcurl.so. You can refer to my sample project: https://github.com/yushulx/cmake-cpp-barcode-qrcode

sleepingsaint commented 2 years ago

@yushulx thanks for the suggestion. I did a bit of reading on compilers and standard library implementation in different compilers. The libcurl is compiled using glibc and flutter uses clang compiler. After few trys I got a error which says undefined glibc reference or something of that sort. You think compiling the curl library using clang compiler would resolve the issue?. Can you provide any information you have regarding this compilers and standard library. Thanks in advance :)

yushulx commented 2 years ago

@sleepingsaint sorry, I'm not a compiler expert. My suggestion is if linking the pre-built shared library causes some issues, you can try to take the source code of libcurl as a part of your project.