Reputation: 339
I'm trying to call the dlsym function from a program compiled with the waf build system, but am unable to link libdl using the wscript. This SEEMS like an extremely simple task but I've tried a million different things and have gotten nowhere.
Edit: It would be even better if there were a general way to add flags to the end of each build command. I've tried setting CXXFLAGS and other environment variables but they don't seem to change anything...
Upvotes: 0
Views: 267
Reputation: 245
If you try to pass use=dl
to the build command directly, waf will look in the config environment dict for "uselib variables" to tell it how to handle it.
A minimal wscript to build a simple test.c
program with dl
might look like this:
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 also provides a shorthand to avoid having to explicitly set LIB_DL
:
def configure(conf):
conf.load('compiler_c')
conf.check(lib='dl', uselib_store='DL')
This is somewhat documented here
For the sake of completeness, here's the test.c
file I used to test:
#include <dlfcn.h>
int main(int argc, char** argv)
{
dlopen("some/file", RTLD_LAZY);
return 0;
}
Upvotes: 0