ubuntu下vscode的使用教程_vscode连接ubuntu虚拟机

2022-11-08 17:33:38 浏览数 (1)

大家好,又见面了,我是你们的朋友全栈君。

1、安装ffmpeg

代码语言:javascript复制
wget https://ffmpeg.org/releases/ffmpeg-4.1.tar.bz2
tar -xjvf ffmpeg-4.1.tar.bz2
./configure --prefix=/usr/local/ffmpeg --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-pthreads --enable-libfdk-aac --enable-libmp3lame --enable-libtheora --enable-libx264 --enable-libxvid --enable-libvorbis --enable-shared --enable-avfilter

2、

项目根目录下编写CMakeLists.txt文件

代码语言:javascript复制
# Minimum CMake required                                                                         
cmake_minimum_required(VERSION 3.14.0)

project(demo)

set(CMAKE_BUILD_TYPE "Debug")
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")

set(EXTRA_CXX_FLAGS "-std=c  11 -Wall -Wno-unused-function -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXX_FLAGS}")
message("-- CMAKE_CXX_COMPILER_VERSION: " ${CMAKE_CXX_COMPILER_VERSION})

include_directories(/usr/local/ffmpeg/include)
link_directories(/usr/local/ffmpeg/lib)

add_executable(main demo.cpp)
target_link_libraries(main
    -Wl,--start-group
    avcodec
    avdevice
    avfilter
    avformat
    avutil
    postproc
    swresample
    swscale
    -Wl,--end-group
    pthread)

3、再build文件夹下执行

代码语言:javascript复制
cmake ..
make

4、配置vscode文件

编辑c_cpp_properties.json文件

添加 “/usr/local/ffmpeg/include” 到 “includePath”

代码语言:javascript复制
{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "/usr/local/ffmpeg/include"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "gnu11",
            "cppStandard": "gnu  98",
            "intelliSenseMode": "linux-gcc-x64"
        }
    ],
    "version": 4
}

编辑launch.json

代码语言:javascript复制
{
    // 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": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceRoot}/build/main",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath":"/usr/bin/gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

0 人点赞