我有一個最小的 C 程序#include <libavformat/avformat.h>AVFormatContext *open(const char *url) { printf("URL %s\n", url); AVFormatContext *ctx = NULL; int err = avformat_open_input(&ctx, url, 0, 0); return ctx;}int main(int argc, char **argv) { open(argv[1]);}它可以工作,它打印我傳入的文件路徑,并返回一個有效的 AVFormatContext。我將代碼粘貼到 Golang 程序中:package main// #include <libavformat/avformat.h>// AVFormatContext *open(const char *url) {// printf("URL %s\n", url);// AVFormatContext *ctx = NULL;// int err = avformat_open_input(&ctx, url, 0, 0);// return ctx;// }// #cgo LDFLAGS: -lavformatimport "C"import ( "fmt" "os")func main() { fmt.Println("Lets try this") url := os.Args[1] C.open(C.CString(url))}這會打印URL /dev/urandom(無論我給它什么參數)并掛起。非常奇怪的是,它不打印Lets try this。這是在 Mac 上使用 ffmpeg 并從自制程序轉到:ffmpeg version 4.2.1Copyright (c) 2000-2019 the FFmpeg developers built with Apple clang version 11.0.0 (clang-1100.0.33.8)go version go1.13.4 darwin/amd64我目前的猜測是編譯器 ABI 不兼容,或者 libavformat 在 main() 之前運行某些內容?
- 1 回答
- 0 關注
- 144 瀏覽
添加回答
舉報
0/150
提交
取消