Я пытался, что работает автоматически на Linux в течение нескольких часов, или для Windows.Я хочу связать программу ( PhenoCam , но для этого вопроса только короткую программу ffmpeg, указанную ниже) с ffmpeg.
Настройка
В настоящее время я работаю в Linux,компилирование с помощью mingw и использование Zeranoe ffmpeg builds .Настройка каталога выглядит следующим образом:
dumpVideoInfo.c
+ bin
avformat-54.dll
avutil-51.dll
+ lib
avcodec.lib
avcodec.dll.a
avutil.lib
avutil.dll.a
Проблемы
Попытка динамического связывания с файлами DLL вызывает Формат файла не распознан Ошибка.
$ i586-mingw32msvc-gcc -v -Wall -Iinclude dumpVideoInfo.c -o dumpVideoInfo.exe -L./bin64 -lavformat-54 -lavutil-51
./bin64/avformat-54.dll: file not recognized: File format not recognized
Попытка связать его с .lib / .dll.a вызвала неопределенная ссылка ошибки:
$ i586-mingw32msvc-gcc -v -Wall -Iinclude dumpVideoInfo.c -o dumpVideoInfo.exe -L./lib64 -lavformat -lavutil
/tmp/ccSKJQAc.o:dumpVideoInfo.c:(.text+0x30): undefined reference to `_av_register_all'
/tmp/ccSKJQAc.o:dumpVideoInfo.c:(.text+0x6e): undefined reference to `_avformat_open_input'
/tmp/ccSKJQAc.o:dumpVideoInfo.c:(.text+0xbf): undefined reference to `_avformat_find_stream_info'
/tmp/ccSKJQAc.o:dumpVideoInfo.c:(.text+0xef): undefined reference to `_av_dump_format'
/tmp/ccSKJQAc.o:dumpVideoInfo.c:(.text+0xfe): undefined reference to `_av_free'
Частичное решение
Как уже было указанокаталоги bin64 / lib64 выше, я использовал 64-битные библиотеки.Приведенные выше ошибки исчезли после перехода на 32-разрядные библиотеки.
Остальные проблемы
- Независимо от того, ссылаюсь ли я на каталог bin / или lib / (.dll или .lib /).dll.a) полученный исполняемый файл остается 23 КБ и по-прежнему требует файлы .dll.Как я могу статически связать программу?
- В чем разница между файлами .lib и .dll.a?
Код
#include <stdio.h>
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
int main(int argc, char *argv[])
{
char *filename;
if (argc > 1) {
filename = argv[1];
} else {
printf("No video file given.");
return 2;
}
av_register_all();
AVFormatContext *pFormatContext = NULL;
printf("Reading info for file %s.\n", filename);
fflush(stdout);
int ret;
if ((ret = avformat_open_input(&pFormatContext, filename, NULL, NULL)) != 0) {
printf("Could not open file %s.\n", filename);
return 2;
}
if (avformat_find_stream_info(pFormatContext, NULL) < 0) {
printf("No stream information found.\n");
return 2;
}
av_dump_format(pFormatContext, 0, filename, 0);
av_free(pFormatContext);
return 0;
}
Спасибо за ваши ответы.