我正在编写一些使用cgo与gstreamer-1.0库交互的东西。我几乎所有的东西都工作得很完美,但是由于某种原因,整个头文件的对象没有被正确导入。
无论值多少钱都要go version go1.15.2 linux/amd64
package main
// #cgo pkg-config: gstreamer-1.0
// #cgo CFLAGS: -Wno-deprecated-declarations
// #include <gst/gst.h> // using this file extensively with no issues
// #include <gst/app/gstappsink.h> // objects in this file are not getting read, but the compiler is having no issue reading it
import "C"
func init () { C.gst_init(nil, nil) }
func main () {
// ...
C.gst_app_sink_pull_sample() // a non-variadic function that does take args
// but cgo doesn't even think it exists.
// ...
}编译器返回的错误:/tmp/go-build/cgo-gcc-prolog:64: undefined reference to 'gst_app_sink_pull_sample'
我已经查看了头文件,gst_app_sink_pull_sample确实存在。我既可以在本地构建,也可以在golang坞容器中复制。
如果完全删除include,则错误是不同的:could not determine kind of name for C.gst_app_sink_pull_sample。
所以我是问题还是gstreamer的问题?
发布于 2020-09-20 19:24:58
appsrc和app接收器符号不是基本gstreamer库的一部分。相反,它们可以在额外的库gstreamer-app-1.0中找到。将此库添加到行中,它将找到缺少的符号。
发布于 2020-09-21 10:15:54
“对xxx的未定义引用”是指cgo的C编译器识别这些定义,但它找不到实现(包括在相应的C库中)
这表示您的C头文件导入正确。为了解决未定义的引用问题,如果动态库名为libgStreer.so.1.0.0,则只需添加如下内容
# cgo LDFLAGS: -lgstreamerhttps://stackoverflow.com/questions/63965349
复制相似问题