asticode/go-astiav

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

onthegit opened this issue · 6 comments

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

If I directly specify:
#include "./tmp/n5.1.2/include/libavfilter/buffersink.h"

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

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

PKG_CONFIG_PATH in go.toolsEnvVars did not have effect.

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

@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.

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 "$@"