asticode / go-astiav

Golang ffmpeg and libav C bindings
MIT License
393 stars 45 forks source link

fatal error: libavfilter/buffersink.h: No such file or directory #24

Closed onthegit closed 1 year ago

onthegit commented 1 year ago

Hello, I am using vscode for editor. But the go language server is complaining that it can not find libavfilter/buffersink.h /buffersink_flag.go:4:10: fatal error: libavfilter/buffersink.h: No such file or directory

settings.json:

{
  "go.toolsEnvVars": {
    "CGO_ENABLED": "1",
    "CGO_LDFLAGS": "-L${workspaceFolder}/tmp/n5.1.2/lib",
    "CGO_CXXFLAGS": "-I${workspaceFolder}/tmp/n5.1.2/include",
    "PKG_CONFIG_PATH": "${workspaceFolder}/tmp/n5.1.2/lib/pkgconfig",
  },
}

The files are there in tmp/n5.1.2/include/

 ls tmp/n5.1.2/include/
libavcodec   libavfilter  libavutil    libswresample
libavdevice  libavformat  libpostproc  libswscale

ls tmp/n5.1.2/include/libavfilter/
avfilter.h    buffersrc.h  version_major.h
buffersink.h  version.h
onthegit commented 1 year ago

If I directly specify:

include "./tmp/n5.1.2/include/libavfilter/buffersink.h"

it works, but that is not the solution. Help?

onthegit commented 1 year ago

I managed to get it working by setting up a custom pkgconfig in bash script that sets the PKG_CONFIG_PATH to the path in tmp. I don't know if it is the right way but it works:

{
  "go.toolsEnvVars": {
    "CGO_ENABLED": "1",
    "CGO_LDFLAGS": "-L${workspaceFolder}/tmp/n5.1.2/lib",
    "CGO_CXXFLAGS": "-I${workspaceFolder}/tmp/n5.1.2/include",
    "PKG_CONFIG": "${workspaceFolder}/pkgconfig",
  },
}

I also modified libavfilter.pc for the correct directories

onthegit commented 1 year ago

PKG_CONFIG_PATH in go.toolsEnvVars did not have effect.

asticode commented 1 year ago

What if you use CGO_CFLAGS instead of CGO_CXXFLAGS in your first configuration?

onthegit commented 1 year ago

@asticode Does not work. The problem is pkg-config not finding the the config. I could not find a way to set PKG_CONFIG_PATH in vscode for go tools (for intellisense) except by manually overriding the PKG_CONFIG variable as shown in settings.json above.

onthegit commented 1 year ago

the pkgconfig bash script in my workspace folder is:

#!/bin/bash
export PKG_CONFIG_PATH=/home/user/dev/golang/go-astiav/tmp/n5.1.2/lib/pkgconfig
/usr/bin/pkg-config "$@"