dsf4354353452 2018-08-20 10:43
浏览 190
已采纳

运行带有dep的vet时找不到头文件

I get this error when running go vet in my project, with vendored dependencies.

$ go vet ./...
# <project path...>/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1
vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/curve.go:42:10: fatal error: libsecp256k1/include/secp256k1.h: No such file or directory
 #include "libsecp256k1/include/secp256k1.h"

I thought that this was a dependency missing in the development environment, but when looking at the original project source, the include path is relative to the source file.

Why can the file not be found?

  • 写回答

2条回答 默认 最新

  • duanchendu69495 2018-08-20 10:43
    关注

    Some dependency management tools for go do not vendor all code that is referenced by the project. This means that in some circumstances C code, that can be used in go files with cgo, are not included in the vendor directory.

    I have encountered this issue twice with two separate vendoring tools, but there is work to support these use cases.

    The simplest method I have found so far is to use govendor and then import the complete directory to ensure that all the required files are there. This is a very simple solution that ignores a lot of the complexity around including c dependencies in go projects, but fixes the issue whilst there is no permanent fix for the issue.

    go get github.com/kardianos/govendor
    govendor init
    govendor add +e
    # Remove the directory that is missing the c dependencies
    rm -rf ./vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/
    # Add the file and include all files
    # https://github.com/kardianos/govendor/issues/247
    govendor add github.com/ethereum/go-ethereum/crypto/secp256k1/^
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题