我试图从用waf构建系统编译的程序调用dlsym函数,但是无法使用wscript链接libdl。这似乎是一个非常简单的任务,但我尝试了无数种不同的东西,但却一无所获。
编辑:如果有一种通用的方法将标志添加到每个构建命令的末尾,那就更好了。我尝试过设置CXXFLAGS和其他环境变量,但它们似乎没有改变任何东西.
发布于 2020-03-19 15:58:38
如果您试图直接将use=dl传递给build命令,waf将在配置环境dict中查找"uselib变量“,告诉它如何处理它。
使用test.c构建一个简单的dl程序的最小wscript可能如下所示:
def options(opt):
opt.load('compiler_c')
def configure(conf):
conf.load('compiler_c')
# Make sure the we're able to link against dl
conf.check(lib='dl')
# If someone passes LIB_DL, to the build command, link against system library dl
conf.env.LIB_DL = 'dl'
def build(bld):
bld(source='test.c',
target='test_program',
features='c cprogram',
# Waf will look in LIB_DL, LIBPATH_DL, CXXFLAGS_DL, etc. for how to handle this
use='DL')Waf还提供了一个速记,以避免显式设置LIB_DL。
def configure(conf):
conf.load('compiler_c')
conf.check(lib='dl', uselib_store='DL') 这在某种程度上是文档化的这里
为了完整起见,下面是我用来测试的test.c文件:
#include <dlfcn.h>
int main(int argc, char** argv)
{
dlopen("some/file", RTLD_LAZY);
return 0;
}https://stackoverflow.com/questions/58699771
复制相似问题