c - 如何在 C 中编译一个简单的 MLT 示例?
问题描述
我正在尝试从MLT Framework 网站编译一个示例代码,该代码显示消费者/生产者的工作方式。代码如下:
#include <stdio.h>
#include <unistd.h>
#include <framework/mlt.h>
int main( int argc, char *argv[] )
{
// Initialise the factory
if ( mlt_factory_init( NULL ) == 0 )
{
// Create the default consumer
mlt_consumer hello = mlt_factory_consumer( NULL, NULL );
// Create via the default producer
mlt_producer world = mlt_factory_producer( NULL, argv[ 1 ] );
// Connect the producer to the consumer
mlt_consumer_connect( hello, mlt_producer_service( world ) );
// Start the consumer
mlt_consumer_start( hello );
// Wait for the consumer to terminate
while( !mlt_consumer_is_stopped( hello ) )
sleep( 1 );
// Close the consumer
mlt_consumer_close( hello );
// Close the producer
mlt_producer_close( world );
// Close the factory
mlt_factory_close( );
}
else
{
// Report an error during initialisation
fprintf( stderr, "Unable to locate factory modules\n" );
}
// End of program
return 0;
}
文件名为 player.c。
我不能使用 make 来编译它,make player
因为它找不到包含文件。
我正在使用以下命令使用 gcc 进行编译:
# gcc -I /usr/include/mlt -l libmltcore -o player player.c
/usr/bin/ld: cannot find -llibmltcore
collect2: error: ld returned 1 exit status
如您所见,链接器找不到 mlt 库。操作系统是 Fedora 32,我已经安装了 mlt-devel,我确信我在 /usr/lib64/mlt 中有以下库:
libmltavformat.so libmltlinsys.so libmltqt.so libmltvidstab.so
libmltcore.so libmltmotion_est.so libmltresample.so libmltvmfx.so
libmltdecklink.so libmltnormalize.so libmltrtaudio.so libmltvorbis.so
libmltfrei0r.so libmltoldfilm.so libmltsdl2.so libmltxml.so
libmltgtk2.so libmltopengl.so libmltsdl.so
libmltjackrack.so libmltplusgpl.so libmltsox.so
libmltkdenlive.so libmltplus.so libmltvideostab.so
我究竟做错了什么?
我的第二个问题是为什么 GCC 首先找不到包含文件和库,所以我必须手动指定它们?
解决方案
关于:
gcc -I /usr/include/mlt -l libmltcore -o player player.c`
链接器按照命令中列出的顺序处理事物。因此,当链接器遇到-l libmitcore
没有未解析的外部引用时,因此没有包含任何内容,因此最后链接步骤将失败。建议:
gcc player.c -o player -I /usr/include/mlt -l libmltcore
关于:
/usr/bin/ld: cannot find -llibmltcore
如果libmltcore
不在“标准”库目录之一上,则不会找到它,除非该命令还包括库路径。建议在库名称之前包含以下参数:
-L /usr/lib64/mlt
推荐阅读
- variables - 如何从 terraform variable.tf 文件中的另一个变量创建一个变量?
- python - 如何在django中获取登录用户的数据
- angular - 将角度组件添加到非角度第三方组件
- python - python:符号查找错误:/lib/x86_64-linux-gnu/libGLX_mesa.so.0:未定义符号:xcb_dri3_get_supported_modifiers
- python - TypeError: MinMaxScaler 不支持稀疏输入。考虑改用 MaxAbsScaler
- javascript - 动作分派后 Redux 状态未更新
- flutter - 有没有办法将sliding_up_panel 高度设置为灵活(例如缩放到内容)
- sql - 我可以在 Oracle 和 PostgreSQL 中用于 BITWISE 函数的最大数值是多少?
- android-recyclerview - Android:延迟显示复选框
- javascript - Firefox canvas.captureStream 捕获处于非活动状态的黑框