#include <glib/poppler.h>int main() {return 0;}
gcc poppler.c -o p `pkg-config --cflags poppler-glib`
package main
/*
#cgo pkg-config: --cflags poppler-glib
#include <glib/poppler.h>
*/
import "C"
import "fmt"
func main() {
var p *C.PopplerDocument
fmt.Println(p)
}
...with this command:
$ go install
.\poppler.go:5:26: fatal error: glib/poppler.h: No such file or directory
compilation terminated.
Output of pkg-config --cflags poppler-glib:
-pthread -mms-bitfields -I/mingw64/include/poppler/glib -I/mingw64/include/poppler -I/mingw64/include/cairo -I/mingw64/include/pixman-1 -I/mingw64/include -I/mingw64/include/freetype2 -I/mingw64/include/libpng16 -I/mingw64/include/harfbuzz -I/mingw64/include/glib-2.0 -I/mingw64/lib/glib-2.0/include -I/mingw64/include -I/mingw64/include/freetype2 -I/mingw64/include -I/mingw64/include/harfbuzz -I/mingw64/include/glib-2.0 -I/mingw64/lib/glib-2.0/include -I/mingw64/include/libpng16
Replace [`pkg-config --cflags poppler-glib`] with [-I/mingw64/include/poppler] in C; build fails:
$ gcc poppler.c -o p -I/mingw64/include/poppler
In file included from poppler.c:1:0:
C:/msys64/mingw64/include/poppler/glib/poppler.h:22:25: fatal error: glib-object.h: No such file or directory
compilation terminated.
So it found glib/poppler.h and now it needs glib-object.h. That's fine. Replace [#cgo pkg-config: --cflags poppler-glib] with [#cgo CFLAGS: -I/mingw64/include/poppler] in Go; build fails:
$ go install
.\poppler.go:5:26: fatal error: glib/poppler.h: No such file or directory
compilation terminated.
So the problem is likely not pkg-config, but how Go/cgo handles the path indicated in the -I flag. I've tried replacing [-I/mingw64/include/poppler] with [-Ic:\\msys64\\mingw64\\include\\poppler] but that isn't valid.
Any clues as to why this is happening?
How do you setup a Go dev environment in MSYS2?
Any ideas how to fix this problem in a more general way?I have a feeling that this has something to do with the difference between msys2 and mingw64, so I'm going to read some more now.