尝试在cgo中使用dylib动态库失败,报“dyld: Library not returned”

李逍遥*_*李逍遥 5 rpath dylib go cgo

我尝试在cgo中导入dylib动态库,但失败。这是我的代码。

\n\n
package main\n//#cgo CFLAGS: -I./yun2txt/include\n//#cgo LDFLAGS: -L./yun2txt/lib -ltotxt\n//\n//#include <library.h>\nimport "C"\n\nfunc main() {\n    C.hello()\n}\n\n
Run Code Online (Sandbox Code Playgroud)\n\n

也有错误。

\n\n
dyld: Library not loaded: @rpath/libtotxt.dylib\n  Referenced from: /private/var/folders/2n/k70s3c1j08q2z_6kw06n13nh0000gn/T/___go_build_cgo\n  Reason: image not found\n\n
Run Code Online (Sandbox Code Playgroud)\n\n

我该如何解决这个问题\xef\xbc\x9f

\n