今天新加入一些模块,遇到了一个问题
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
)
在遇到Meson构建系统中关于未定义的dlopen、dlerror等动态链接库错误时,解决方案是在meson.build文件中添加cc.find_library('dl', required: true)来寻找dl库。这将确保编译时正确链接dl库,从而避免编译错误。
6979

被折叠的 条评论
为什么被折叠?



