webp icon indicating copy to clipboard operation
webp copied to clipboard

Problem with macos build

Open mchusovlianov opened this issue 5 years ago • 12 comments

I try to build application which use webp library and can't build it with enabled CGO: GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 go build -ldflags "-X main.Version=2.1.29 -X main.Build=`git rev-parse HEAD` -X main.BuildTime=`date +%FT%T%z`" -o bin I have gcc installed. image

mchusovlianov avatar Oct 23 '18 10:10 mchusovlianov

facing the same issue. just curious. are you using go modules?

ns3777k avatar Feb 21 '19 23:02 ns3777k

Having the same issue here. I'm trying to migrate my project to go modules :/

solher avatar Mar 01 '19 16:03 solher

if you take a look inside the vendor folder, you won't find internal directory where webp.h should be located. since i commit my vendor directory, i just git clone this repo inside vendor directory. there probably should be a better way =\

ns3777k avatar Mar 01 '19 16:03 ns3777k

I just found the solution actually. The go modules tool is not able to resolve C dependencies so it doesn't see that some .c/.h files are actually in the internal package of the chai2010/webp lib. Just copy it by hand in the vendor folder and it should work :)

solher avatar Mar 01 '19 16:03 solher

Hahaha perfect #RaceCondition

solher avatar Mar 01 '19 16:03 solher

@ns3777k I'm facing same issue with govendor, with govendor you can install this package via

govendor fetch github.com/chai2010/webp/^

More details please refer to kardianos/govendor#137 and here.

coldnight avatar Mar 19 '19 08:03 coldnight

For now, Go module prunes non-package directories, see more discussions in golang/go#26366.

coldnight avatar Mar 19 '19 09:03 coldnight

Some useful tools:

  • https://github.com/nomad-software/vend
  • https://github.com/goware/modvendor

coldnight avatar Mar 19 '19 09:03 coldnight

Is there a way to fix this bug on inside chai2010/webp? I feed like go vendoring is much less useful if you need to utilize external tools to make it work...

kosta avatar Jun 13 '19 14:06 kosta

I don't think we can find a way to fix this bug inside this project, this is kind a issue(feature lacking) of go mod.

coldnight avatar Jun 13 '19 15:06 coldnight

For those coming across this issue who are using dep, a workaround is to add

[prune]
  go-tests = true
  unused-packages = true

  [[prune.project]]
    name = "github.com/chai2010/webp"
    go-tests = false
    unused-packages = false

to your Gopkg.toml to stop the pruning of the C code.

pci avatar Sep 18 '19 15:09 pci

@chai2010, good day. The issue is still actual for go mod dependency management with vendoring. Should we expect any changes that would make module to be downloaded with internals via go mod?

furiousassault avatar Sep 19 '19 04:09 furiousassault