1project('shared module', 'c') 2 3c = meson.get_compiler('c') 4 5# Windows UWP doesn't support the ToolHelp API we use in this test to emulate 6# runtime symbol resolution. 7if host_machine.system() == 'windows' 8 if not c.compiles(''' 9#include <windows.h> 10#include <tlhelp32.h> 11 12HANDLE func(void) 13{ 14 return CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, 0); 15} 16''') 17 error('MESON_SKIP_TEST Windows UWP does not support this test.') 18 endif 19endif 20 21dl = c.find_library('dl', required : false) 22l = shared_library('runtime', 'runtime.c') 23# Do NOT link the module with the runtime library. This 24# is a common approach for plugins that are only used 25# with dlopen. Any symbols are resolved dynamically 26# at runtime. This requires extra help on Windows, so 27# should be avoided unless really necessary. 28m = shared_module('mymodule', 'module.c') 29e = executable('prog', 'prog.c', 30 link_with : l, export_dynamic : true, dependencies : dl) 31test('import test', e, args : m) 32 33# Same as above, but module created with build_target() 34m2 = build_target('mymodule2', 'module.c', target_type: 'shared_module') 35test('import test 2', e, args : m2) 36 37# Shared module that does not export any symbols 38shared_module('nosyms', 'nosyms.c', 39 install : true, 40 install_dir : join_paths(get_option('libdir'), 'modules')) 41