dongyata3336 2016-02-07 18:47
浏览 31
已采纳

找不到共享库的软件包

I am trying to use a shared library in go-lang, I am following this blog post: http://blog.ralch.com/tutorial/golang-sharing-libraries/

But when I hit build I get back an error:

simo@simo:~/gopath$ go build -linkshared -o app effe/prova
src/effe/prova/prova.go:3:8: cannot find package "libmath" in any of:
/usr/local/go/src/libmath (from $GOROOT)
/home/simo/gopath/src/libmath (from $GOPATH)

I am pretty new to go, so I will show also my environment...

simo@simo:~/gopath$ pwd
/home/simo/gopath
simo@simo:~/gopath$ echo $GOPATH
/home/simo/gopath
simo@simo:~/gopath$ tree
.
├── pkg
│   └── linux_amd64_dynlink
│       ├── effe
│       │   ├── libmath.a
│       │   └── libmath.shlibname
│       └── libeffe-libmath.so
└── src
    └── effe
        ├── libmath
        │   └── libmath.go
        └── prova
            └── prova.go

7 directories, 5 files
simo@simo:~/gopath$ cat src/effe/libmath/libmath.go 
// filename: libmath.go
package libmath

func Sum(x, y int) int {
    return x + y
}
simo@simo:~/gopath$ cat src/effe/prova/prova.go 
package main

import "libmath"
import "fmt"

func main() {
    fmt.Printf("5 op 10 => %d", libmath.Sum(5, 10))
}
simo@simo:~/gopath$ go install -buildmode=shared -linkshared effe/libmath
simo@simo:~/gopath$ go build -linkshared -o app effe/prova
src/effe/prova/prova.go:3:8: cannot find package "libmath" in any of:
    /usr/local/go/src/libmath (from $GOROOT)
    /home/simo/gopath/src/libmath (from $GOPATH)

What am I doing wrong ?

  • 写回答

1条回答 默认 最新

  • dongxu8533486 2016-02-07 18:53
    关注

    The import path for "libmath" is "effe/libmath".

    Try to get your build working in the standard build mode before experimenting with more complicated build and execution modes.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化