0

我正在尝试构建一个 obs 插件,但我对它所涉及的所有内容(c++、CMake 和 obs 插件生态系统)都是新手。因此,我尝试根据现有插件https://github.com/royshil/obs-backgroundremoval制作自己的

在我开始进行代码更改之前,我做了一些字符串更改并构建了插件来测试一切是否正常,一切都很好。但是,当我尝试链接 curlpp 以发送 HTTP 请求时,插件不再加载,并且当插件尝试在 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_

(由于某种原因,该符号被混淆了,但是如果您删除多余的字符,您会发现它是curlpp::OptionBase

经过一番研究,我想我需要以某种方式链接库,所以我尝试以类似于 GitHub repo 链接的方式进行操作Onnxruntime

外部/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()

CMakeLists.txt我做了以下更改:

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}
)

但我仍然得到同样的错误。你能帮我找出我错过了什么吗?

4

0 回答 0