今天新加入一些模块,遇到了一个问题
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
)