1

I'm trying to build an obs-plugin, but I'm new to everything involved with it (c++, CMake, and the obs-plugin ecosystem). So, I tried to make my own based on the existing plugin https://github.com/royshil/obs-backgroundremoval

I made some string changes and built the plugin to test that everything is working before I started making code changes and all is good. But when I tried to link curlpp to send an HTTP request the plugin doesn't load anymore and I get the following error when the plugin tries to load in OBS:

os_dlopen(/home/user/.config/obs-studio/plugins/obs-backgroundremoval/bin/64bit/obs-backgroundremoval.so->/home/user/.config/obs-studio/plugins/obs-backgroundremoval/bin/64bit/obs-backgroundremoval.so): /home/user/.config/obs-studio/plugins/obs-backgroundremoval/bin/64bit/obs-backgroundremoval.so: undefined symbol: _ZNK6curlpp10OptionBaseltERKS0_

(the symbol is obfuscated for some reason, but if you remove the extra characters you can find it is curlpp::OptionBase)

After some research, I figured I need to link the library somehow, so I tried to do it similar to the way that the GitHub repo linked Onnxruntime.

external/FindCurlpp.cmake

find_path(Curlpp_INCLUDE_DIR
        NAMES
            "curlpp/cURLpp.hpp"
            "curlpp/Easy.hpp"
            "curlpp/Options.hpp"
            "curlpp/Exception.hpp"
        PATHS
            /usr/share/include ~/Downloads/curlpp-0.8.1/include
        DOC "Curlpp include directory")



include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set LOGGING_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(Curlpp DEFAULT_MSG Curlpp_INCLUDE_DIR)

if (Curlpp_FOUND)
    set(Curlpp_INCLUDE_DIRS ${Curlpp_INCLUDE_DIR} CACHE STRING "Curlpp include directories")
    list(GET Curlpp_LIBRARIES 0 Curlpp_LIBRARY)
    get_filename_component(Curlpp_LIBRARY_DIR_EX ${Curlpp_LIBRARY} DIRECTORY)
    set(Curlpp_LIBRARY_DIR ${Curlpp_LIBRARY_DIR_EX} CACHE STRING "Curlpp library directory")
#else()
#    error("")
endif()

and in CMakeLists.txt I made the following changes:

find_package(CURL REQUIRED) # added

find_package(Curlpp REQUIRED) # added

find_package(Onnxruntime REQUIRED)

find_package(OpenCV 4.2 REQUIRED COMPONENTS core imgproc)

include_directories(
    ${LIBOBS_INCLUDE_DIR}/../UI/obs-frontend-api
    ${LIBOBS_INCLUDE_DIR}
    ${LIBOBS_INCLUDE_DIRS}
    ${Curlpp_INCLUDE_DIRS} # added
    ${Onnxruntime_INCLUDE_DIRS}
    ${OpenCV_INCLUDE_DIRS}
)

target_link_libraries(${CMAKE_PROJECT_NAME}
    ${LIBOBS_LIBRARIES}
    CURL::libcurl # added
    ${Onnxruntime_LIBRARIES}
    ${OpenCV_LIBRARIES}
)

But I still get the same error. Could you help me find what am I missing?

Sweta Jain
  • 3,248
  • 6
  • 30
  • 50
Maed Hamed
  • 11
  • 1
  • 2
  • Are those plus sign "+" in your cmake file? – Louis Go Nov 15 '21 at 01:52
  • @LouisGo no, I just added them here to showcase the changes I made. – Maed Hamed Nov 15 '21 at 02:04
  • I'll suggest to use `# added` as notion since everyone find a `+` would be confused. Sorry I cannot answer your question, but I might help your question get more attention for it by changing the notion. – Louis Go Nov 15 '21 at 02:39
  • Also have you added `set(CMAKE_VERBOSE_MAKEFILE ON)` in your cmake to see what's going on? Post error message you got. – Louis Go Nov 15 '21 at 02:41
  • @LouisGo I updated the code, thx! I'll try that, but everything works fine when building. The error I get is when OBS tries to load the `*.so` file. – Maed Hamed Nov 15 '21 at 05:31
  • Have you checked if `obs-backgroundremoval.so` really has the mangled function named `_ZNK6curlpp10OptionBaseltERKS0_`? Or your built curl has the correct mangled name? I suggest you change the code to reflect the correct function name from the so you built. – Louis Go Nov 15 '21 at 06:42
  • 1
    A plugin is a library of type `MODULE`. When such library is built (and linked), unknown symbols are NOT checked. You need to find out which **exact command line** is used for linking your plugin and to make sure that given command line contains appropriate curlcpp library. Also you need to make sure that curlcpp library which you are linking with actually contains missed symbol in **mangled** form. For find out the linking command line you could build the project with `make VERBOSE=1`. (Before doing such build you need to delete the plugin file, so its linking will actually be performed.) – Tsyvarev Nov 15 '21 at 07:05

0 Answers0