Golang compiler CLI options CGO_CFLAGS_ALLOW
12/01/26 11:37 Filed in: golang
I do a lot of building Golang across platforms (honestly I just prefer the work flow under OS X) but frequently you see messages like
And then Google fails me when you search for the error. It turns out the problem is trivial to fix and that the specific Google search finds lots of things relating to things other than the problem.
The solution:
% go build
gopkg.in/gographics/imagick.v3/imagick: invalid flag in pkg-config --cflags: -Xpreprocessor
And then Google fails me when you search for the error. It turns out the problem is trivial to fix and that the specific Google search finds lots of things relating to things other than the problem.
The solution:
% env CGO_CFLAGS_ALLOW="-Xpreprocessor" go build
And why does this work.
The Go compiler checks the preprocessor directives against a list of acceptable ones. Apparently the relatively common one used on MacOS with homebrew (https://brew.sh)
is not in the list.
The directive
The fascinating thing is while the instruction to add the directive is in the documentation for https://github.com/gographics/imagick/tree/master it does not seem to get connected to the error message in either Google's search or AI summaries.
Something so small and simple that Google doesn't really see it.
The Go compiler checks the preprocessor directives against a list of acceptable ones. Apparently the relatively common one used on MacOS with homebrew (https://brew.sh)
-Xpreprocessoris not in the list.
The directive
CGO_CFLAGS_ALLOW="-Xpreprocessor" is all that is needed to allow this to go to the next phase of compilation. The fascinating thing is while the instruction to add the directive is in the documentation for https://github.com/gographics/imagick/tree/master it does not seem to get connected to the error message in either Google's search or AI summaries.
Something so small and simple that Google doesn't really see it.