【问题标题】:How to use/link meson build Gstreamer in ROS Package?如何在 ROS 包中使用/链接介子构建 Gstreamer?
【发布时间】:2019-12-30 17:46:49
【问题描述】:

为了使用最新的Gstreamer,我使用以下命令构建了新版本。

meson --prefix=/media/jai/Entertainment/Software/gstreamer/gst-build-installed --reconfigure build/  
ninja -C build/  
meson install -C build/

现在我有了这个目录

它也有 pkg​​-configs

我必须在 Cmakelist.txt 和 package.xml 中进行哪些更改才能链接此 Gstreamer?

我尝试了以下更改。但到目前为止还没有运气。

CMakeLists.txt

cmake_minimum_required(VERSION 2.8.3)
project(mypkg)

find_package(catkin REQUIRED COMPONENTS
    roscpp
    sensor_msgs
    std_msgs
    )

SET(ENV{PKG_CONFIG_PATH} "/media/jai/Entertainment/Software/gstreamer/gst-build-installed/lib/x86_64-linux-gnu/pkgconfig" $ENV{PKG_CONFIG_PATH})
SET(ENV{LD_LIBRARY_PATH} "/media/jai/Entertainment/Software/gstreamer/gst-build-installed/lib/x86_64-linux-gnu" $ENV{LD_LIBRARY_PATH})
find_package(PkgConfig REQUIRED)
pkg_check_modules(GST1.0 REQUIRED gstreamer-1.0)

find_package(Boost REQUIRED COMPONENTS thread)

catkin_package(
    CATKIN_DEPENDS roscpp sensor_msgs std_msgs
    DEPENDS Boost GST1.0
    INCLUDE_DIRS include
    LIBRARIES mypkg
    )

include_directories(include ${catkin_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${GST1.0_INCLUDE_DIRS})

add_executable(mypkg src/main.cpp)

add_dependencies(mypkg ${catkin_EXPORTED_TARGETS})

target_link_libraries(mypkg ${catkin_LIBRARIES} ${GST1.0_LIBRARIES} ${Boost_LIBRARIES})

install(TARGETS mypkg
   DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

install(DIRECTORY launch
   DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})

package.xml

<?xml version="1.0"?>
<package format="2">
<name>mypkg</name>
<version>0.1.0</version>
<description>Description</description>

<maintainer email="jai@todo.todo">jai</maintainer>

<license>Apache 2.0</license>

<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>sensor_msgs</build_depend>
<build_depend>pkg-config</build_depend>

<build_export_depend>roscpp</build_export_depend>
<build_export_depend>std_msgs</build_export_depend>
<build_export_depend>sensor_msgs</build_export_depend>
<build_export_depend>boost</build_export_depend>

<exec_depend>roscpp</exec_depend>
<exec_depend>std_msgs</exec_depend>
<exec_depend>sensor_msgs</exec_depend>
<exec_depend>pkg-config</exec_depend>

<export>

</export>
</package>

main.cpp

#include "ros/ros.h"
#include <sensor_msgs/CompressedImage.h>
#include "thread"
#include <boost/thread.hpp>
extern "C"{
#include <gst/gst.h>
#include <gst/app/gstappsink.h>
}
int main(int argc, char **argv)
{
    ros::init(argc, argv, "gstreamer");
    gst_init(&argc, &argv);
    g_print ("**\nGstreamer version: %s\n**\n", gst_version_string ());

    ros::spin();
}

经过以上所有修改,包仍然使用stock gstreamer而不是新的。 输出: jai@jai:~$ rosrun gstreamer gstreamer

************************************
Gstreamer version: GStreamer 1.8.3
************************************
libva info: VA-API version 0.39.4
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_0_39
libva info: va_openDriver() returns 0

我认为它可能能够访问包含文件但不能访问 LIBS。

【问题讨论】:

    标签: cmake linker gstreamer ros pkg-config


    【解决方案1】:

    我认为您需要在设置 PKG_CONFIG_PATH 时使用 :(冒号)来分割路径并注意引号:

    SET(ENV{PKG_CONFIG_PATH} "/media/jai/Entertainment/Software/gstreamer/gst-build-installed/lib/x86_64-linux-gnu/pkgconfig:$ENV{PKG_CONFIG_PATH}")
    

    您还可以使用以下命令仔细检查 gstreamer 版本:

    pkg_get_variable(GST_VERSION gstreamer-1.0 version)
    message(STATUS "Gstreamer version:${GST_VERSION}")
    

    请注意,您的应用应该能够在运行时找到您构建的 gstreamer 库。为使这成为可能,应将它们安装到 LD_LIBRARY_PATH 的已知位置。如@Florian 所述更新此内容,也可用于开发目的,以及使用运行时链接器配置 /etc/ld.so.config。

    PS

    我注意到 gstappsink.h 并想知道您是否在 cmakelists 中缺少另一个 gst 包,例如gstreamer-app-1.0.检查cmake宏find_gstreamer_component

    由 Jai 编辑。

    gedit .bashrc
    
    export LD_LIBRARY_PATH=/media/jai/Entertainment/Software/gstreamer/gst-build-installed/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
    

    【讨论】:

    • 感谢您的回复。 SET(ENV{PKG_CONFIG_PATH} "/media/jai/Entertainment/Software/gstreamer/gst-build-installed/lib/x86_64-linux-gnu/pkgconfig:$ENV{PKG_CONFIG_PATH}") & SET(ENV{PKG_CONFIG_PATH} "/media/jai/Entertainment/Software/gstreamer/gst-build-installed/lib/x86_64-linux-gnu/pkgconfig" $ENV{PKG_CONFIG_PATH})。两者结果都与pkg_get_variable(GST_VERSION gstreamer-1.0 version) - 1.17.0.1(新 gstreamer)相同。在我的 IDE 中,如果我将鼠标悬停在 #include &lt;gst/gst.h&gt; 行上,它会显示新的 gstreamer 标头路径但是 gst_version_string () 在执行期间仍然会给出旧的 gstreamer 版本
    • 那是在运行时。这与建筑不同。尝试使用LD_LIBRARY_PATH 指向您的“新”GStreamer 库。然后它们应该被加载,而不是系统范围内可用的。
    • @FlorianZwoch。我在CMakeLists.txt 中编辑了LD_LIBRARY_PATH。仍然没有链接新的 gstreamer(1.17)。我用完整的CMakeLists.txtPackage.xmlmain.cpp 更新了我的问题
    • 对,Florian 是在谈论运行时链接,而不是构建时,所以这与 cmake 文件无关。您的应用在开始运行时应该能够找到正确的 *.so(对应于构建它的标头)。
    • @FlorianZwoch,谢谢。我gedit .bashrc 并添加了export LD_LIBRARY_PATH=/media/jai/Entertainment/Software/gstreamer/gst-build-installed/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH。它与新的 gstreamer 链接。
    猜你喜欢
    • 2022-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-23
    • 2021-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多