lua加载动态库缺乏相应的系统库
错误信息:
使用lua测试lm2动态库时,加载时出现如下错误
jfyuan@jfy11-B85M-D2V:~/temp/service/soft/code/ginger_resty/cores/lm2/test$ lua lm2_test.lua ./param.txt /home/wlc/SpeechdServer/speechd-centos_6.2-x86_64-0.5.0-20140317150535/modules//lm/res/eng.pred/lm.eng.pred.sh
lua: error loading module 'aicores.liblm2' from file './aicores/liblm2.so':
./aicores/liblm2.so: undefined symbol: pthread_mutexattr_destroy
stack traceback:
[C]: ?
[C]: in function 'require'
lm2_test.lua:1: in main chunk
[C]: ?
而ldd时又看不见需要线程动态库
jfyuan@jfy11-B85M-D2V:~/temp/service/soft/code/ginger_resty/cores/lm2$ ldd liblm2.so
linux-vdso.so.1 => (0x00007fff5cddf000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fd667978000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fd667671000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fd66745b000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd667096000)
/lib64/ld-linux-x86-64.so.2 (0x00007fd668215000)
原因可能是lua的require加载模块会对所有导出函数检查依赖库
解决办法:export LD_PRELOAD=/opt/intel/mkl/lib/intel64/libmkl_core.so:/opt/intel/mkl/lib/intel64/libmkl_sequential.so:/usr/local/lib/libiconv.so.2:/lib/x86_64-linux-gnu/libpthread.so.0
jfyuan@jfy11-B85M-D2V:~/temp/service/soft/code/ginger_resty/cores/lm2/test$ ldd aicores/liblm2.so
linux-vdso.so.1 => (0x00007fffe65e6000)
/opt/intel/mkl/lib/intel64/libmkl_core.so (0x00007f9c43ce4000)
/opt/intel/mkl/lib/intel64/libmkl_sequential.so (0x00007f9c43645000)
/usr/local/lib/libiconv.so.2 (0x00007f9c43360000)
/lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f9c43142000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f9c42e14000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f9c42b0e000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f9c428f8000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f9c42532000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f9c4232e000)
/lib64/ld-linux-x86-64.so.2 (0x00007f9c45462000)