From 47d338c6d3ee61f95307eb1771aa041e0a04ef1a Mon Sep 17 00:00:00 2001 From: Jakub Adam Date: Fri, 26 Jul 2019 18:49:49 +0200 Subject: Fix shared library build for Windows with MSVC and Meson (#328) usrsctp-1.dll built with Meson didn't export any symbols. Meson needs a .def file listing the names of functions to export when creating a shared library on Windows. This patch generates usrsctp.def automatically at build time from the output of "dumpbin /linkermember" run on the static version of usrsctp lib. Kudos to Lennart Grahl for help with fixing broken static build. --- meson.build | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'meson.build') diff --git a/meson.build b/meson.build index 942bbed8..763edf93 100644 --- a/meson.build +++ b/meson.build @@ -183,11 +183,32 @@ endif subdir('usrsctplib') # Build library -usrsctp = library('usrsctp', sources, - dependencies: dependencies, - include_directories: include_dirs, - install: true, - version: meson.project_version()) +if compiler.get_id() == 'msvc' and get_option('default_library') == 'shared' + # Needed by usrsctp_def + find_program('dumpbin') + + usrsctp_static = static_library('usrsctp-static', sources, + dependencies: dependencies, + include_directories: include_dirs) + + usrsctp_def = custom_target('usrsctp.def', + command: [find_program('gen-def.py'), '@INPUT@'], + input: usrsctp_static, + output: 'usrsctp.def', + capture: true) + + usrsctp = shared_library('usrsctp', + link_whole: usrsctp_static, + vs_module_defs: usrsctp_def, + install: true, + version: meson.project_version()) +else + usrsctp = library('usrsctp', sources, + dependencies: dependencies, + include_directories: include_dirs, + install: true, + version: meson.project_version()) +endif # Declare dependency usrsctp_dep = declare_dependency( -- cgit v1.2.3