File tree Expand file tree Collapse file tree 4 files changed +11
-2
lines changed Expand file tree Collapse file tree 4 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ pub const (
77
88// get_shared_library_extension returns the platform dependent shared library extension
99// i.e. .dll on windows, .so on most unixes, .dylib on macos.
10+ [inline ]
1011pub fn get_shared_library_extension () string {
1112 mut res := '.so'
1213 $if macos {
@@ -17,3 +18,10 @@ pub fn get_shared_library_extension() string {
1718 }
1819 return res
1920}
21+
22+ // get_libname returns a library name with the operating system specific extension for
23+ // shared libraries.
24+ [inline ]
25+ pub fn get_libname (libname string ) string {
26+ return '$libname$dl.dl_ext '
27+ }
Original file line number Diff line number Diff line change 11module dl
22
33#include <dlfcn.h>
4+
45pub const (
56 rtld_now = C.RTLD_NOW
67 rtld_lazy = C.RTLD_LAZY
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import dl
66type FNAdder = fn (int , int ) int
77
88fn main () {
9- library_file_path := os.join_path (os.getwd (), 'library $ dl.dl_ext ' )
9+ library_file_path := os.join_path (os.getwd (), dl.get_libname ( 'library' ) )
1010 handle := dl.open (library_file_path, dl.rtld_lazy)
1111 eprintln ('handle: ${ptr_str(handle)} ' )
1212 mut f := & FNAdder (0 )
Original file line number Diff line number Diff line change 77 vexe = os.real_path (os.getenv ('VEXE' ))
88 cfolder = os.dir (@FILE)
99 so_ext = dl.dl_ext
10- library_file_name = os.join_path (cfolder, 'library$so_ext ' )
10+ library_file_name = os.join_path (cfolder, dl. get_libname ( 'library' ) )
1111)
1212
1313fn test_vexe () {
You can’t perform that action at this time.
0 commit comments