From f5c4671bfbad96bf346bd7e9a21fc4317b4959df Mon Sep 17 00:00:00 2001 From: Indrajith K L Date: Sat, 3 Dec 2022 17:00:20 +0530 Subject: Adds most of the tools --- v_windows/v/examples/dynamic_library_loading/use.v | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 v_windows/v/examples/dynamic_library_loading/use.v (limited to 'v_windows/v/examples/dynamic_library_loading/use.v') diff --git a/v_windows/v/examples/dynamic_library_loading/use.v b/v_windows/v/examples/dynamic_library_loading/use.v new file mode 100644 index 0000000..71a0099 --- /dev/null +++ b/v_windows/v/examples/dynamic_library_loading/use.v @@ -0,0 +1,17 @@ +module main + +import os +import dl + +type FNAdder = fn (int, int) int + +fn main() { + library_file_path := os.join_path(os.getwd(), dl.get_libname('library')) + handle := dl.open_opt(library_file_path, dl.rtld_lazy) ? + eprintln('handle: ${ptr_str(handle)}') + mut f := FNAdder(0) + f = dl.sym_opt(handle, 'add_1') ? + eprintln('f: ${ptr_str(f)}') + res := f(1, 2) + eprintln('res: $res') +} -- cgit v1.2.3