meson `dlopen‘问题

在遇到Meson构建系统中关于未定义的dlopen、dlerror等动态链接库错误时,解决方案是在meson.build文件中添加cc.find_library('dl', required: true)来寻找dl库。这将确保编译时正确链接dl库,从而避免编译错误。
摘要由CSDN通过智能技术生成

今天新加入一些模块,遇到了一个问题

test.c:(.text+0x1a): undefined reference to `dlopen'
test.c:(.text+0x24): undefined reference to `dlerror'
test.c:(.text+0x32): undefined reference to `dlsym'
test.c:(.text+0x38): undefined reference to `dlerror'
test.c:(.text+0x50): undefined reference to `dlsym'
test.c:(.text+0x56): undefined reference to `dlerror'
test.c:(.text+0x6a): undefined reference to `dlclose'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

经查,这个问题是要加入ldl动态库,在cmake以及makefile里倒是简单,但是在meson里,就不那么容易了。

解决方法如下:

meson.build里加入
libdl = cc.find_library('dl',required:true) 
这句话的意思是找到dl的so

然后再需要编译的目录里的meson.build里加入libdl即可编译通过

 executable('videosink', videosink_sources,
  include_directories : [tizen_inc,videosink_inc, jsoncpp_inc],
  dependencies : [libdl,libpthread,tizen_dep,gstvideo_dep, gstaudio_dep, gstbase_dep, gstcontroller_dep,
                  libm, gmodule_dep, gstallocators_dep, jsoncpp_dep],
  install : true
  )
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值