如何use/link介子在ROS包中构建Gstreamer?

How to use/link meson build Gstreamer in ROS Package?

为了使用最新的 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 到 link 这个 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();
}

经过上述所有修改后,软件包仍在使用原装 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。

我认为您在设置 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 所述,更新它也可以用于开发目的,以及使用 运行time linker config /etc/ld.so.config.

PS

我注意到 gstappsink.h 想知道您的 cmakelists 中是否遗漏了另一个 gst 包,例如gstreamer-应用程序-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