Attempt to use dylib dynamic library in cgo fails, report “dyld: Library not loaded”

Viewed 326

I tried to import the dylib dynamic library in cgo, but it failed. Here is my code.

package main
//#cgo CFLAGS: -I./yun2txt/include
//#cgo LDFLAGS: -L./yun2txt/lib -ltotxt
//
//#include <library.h>
import "C"

func main() {
    C.hello()
}

There are also errors.

dyld: Library not loaded: @rpath/libtotxt.dylib
  Referenced from: /private/var/folders/2n/k70s3c1j08q2z_6kw06n13nh0000gn/T/___go_build_cgo
  Reason: image not found

How can I solve this problem?

0 Answers
Related