gcc 如何在UBUNTU上配置Visual Studio代码以编译gstreamer文件

l2osamch  于 2022-11-13  发布在  其他
关注(0)|答案(2)|浏览(158)

我已经在UBUNTU 18.04上安装了gstreamer和VSC,我可以使用下面的说明从系统命令提示符编译和运行gstreamer教程:https://gstreamer.freedesktop.org/documentation/installing/on-linux.html?gi-language=c
具体来说,我可以编译并运行(视频弹出并播放):
gcc basic-tutorial-1.c -o basic-tutorial-1pkg-config --cflags --libs gstreamer-1.0`
我甚至可以编译,但不能从VSC内部的终端/bash运行。

我不能做的是使用VSC IDE编译或调试代码。我已经尝试使用上述gstreamer教程中建议的命令配置tasks.json文件,如下所示。

当我尝试使用ctr-f5从IDE运行时,我得到了下面的结果。

如果我单击“显示错误”,我会看到以下内容:

任何帮助都是非常感谢的。干杯!

qxsslcnc

qxsslcnc1#

一旦我足够聪明,能够查看终端以查看tasks.json文件中正在执行的任务,我就发现args数组中的每一项都需要是单独的项。

然后从VSC编译并运行sweet gstreamer教程。

同样,如果你想使用Code::Blocks,你必须在编译器和链接器的“other command”区域输入pkg-config --cflags --libs gstreamer-1.0字符串。注意,在上面的字符串中有一些需要的回退标记,但堆栈溢出编辑器已经删除了。请参见gstreamer page

oyxsuwqo

oyxsuwqo2#

按照https://gstreamer.freedesktop.org/documentation/installing/on-linux.html?gi-language=c中的步骤操作
对于Ubuntu 16.04,请遵循https://github.com/mavlink/qgroundcontrol/issues/4303

list=$(apt-cache --names-only search ^gstreamer1.0-* | awk '{ print $1 }' | grep -v gstreamer1.0-hybris)
sudo apt-get install $list

对于Ubuntu 16.04,您还可以遵循https://github.com/jackersson/env-setup/blob/master/gst-ubuntu-16-py/Dockerfile
确保gst-launch-1.0 videotestsrc ! videoconvert ! fakesink正常工作。
以下是我在Ubuntu上使用IntelliSense在VS代码中构建和调试GStreamer时使用的设置。

.vscode/c_cpp_属性.json

(got在所有库的终端中运行pkg-config --cflags --libs gstreamer-video-1.0 gtk+-3.0 gstreamer-1.0

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "/usr/lib/x86_64-linux-gnu/glib-2.0/include",
                "/usr/include/glib-2.0",
                "/usr/lib/x86_64-linux-gnu/gstreamer-1.0/include/",
                "/usr/include/gstreamer-1.0",
                "/usr/lib/x86_64-linux-gnu/dbus-1.0/include",
                "/usr/include/gtk-3.0",
                "/usr/include/at-spi2-atk/2.0",
                "/usr/include/at-spi-2.0",
                "/usr/include/dbus-1.0",
                "/usr/include/gio-unix-2.0",
                "/usr/include/cairo",
                "/usr/include/pango-1.0",
                "/usr/include/harfbuzz",
                "/usr/include/atk-1.0",
                "/usr/include/pixman-1",
                "/usr/include/uuid",
                "/usr/include/freetype2",
                "/usr/include/gdk-pixbuf-2.0",
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "gnu11",
            "cppStandard": "gnu++14",
            "intelliSenseMode": "linux-gcc-x64",
            "configurationProvider": "ms-vscode.cmake-tools"
        }
    ],
    "version": 4
}

.vscode/任务.json

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: gcc build active file",
            "command": "/usr/bin/gcc",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}",
                "`",
                "pkg-config",
                "--cflags",
                "--libs",
                "gstreamer-1.0",
                "gstreamer-audio-1.0",
                "gstreamer-video-1.0",
                "gtk+-3.0",
                "gstreamer-pbutils-1.0",
                "`"
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}

.vscode/启动.json

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "gcc - Build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [
                "-e", "playbin", "uri=https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm"
            ],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: gcc build active file",
            "miDebuggerPath": "/usr/bin/gdb"
        }
    ]
}

.vscode/设置.json

{
    "C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: Google, IndentWidth: 2, ColumnLimit: 0}",
    "files.associations": {
        "string": "c",
        "gst.h": "c",
        "gstdio.h": "c",
        "gprintf.h": "c",
        "gstbin.h": "c",
        "gstbuffer.h": "c",
        "gstbufferpool.h": "c"
    },
    "C_Cpp.errorSquiggles": "Enabled"
}

奖金:https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-ssh

相关问题