mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
dl: add get_libname
function (#8909)
This commit is contained in:
parent
fd59182659
commit
fcc2094719
@ -7,6 +7,7 @@ pub const (
|
|||||||
|
|
||||||
// get_shared_library_extension returns the platform dependent shared library extension
|
// get_shared_library_extension returns the platform dependent shared library extension
|
||||||
// i.e. .dll on windows, .so on most unixes, .dylib on macos.
|
// i.e. .dll on windows, .so on most unixes, .dylib on macos.
|
||||||
|
[inline]
|
||||||
pub fn get_shared_library_extension() string {
|
pub fn get_shared_library_extension() string {
|
||||||
mut res := '.so'
|
mut res := '.so'
|
||||||
$if macos {
|
$if macos {
|
||||||
@ -17,3 +18,10 @@ pub fn get_shared_library_extension() string {
|
|||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get_libname returns a library name with the operating system specific extension for
|
||||||
|
// shared libraries.
|
||||||
|
[inline]
|
||||||
|
pub fn get_libname(libname string) string {
|
||||||
|
return '$libname$dl.dl_ext'
|
||||||
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
module dl
|
module dl
|
||||||
|
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
|
||||||
pub const (
|
pub const (
|
||||||
rtld_now = C.RTLD_NOW
|
rtld_now = C.RTLD_NOW
|
||||||
rtld_lazy = C.RTLD_LAZY
|
rtld_lazy = C.RTLD_LAZY
|
||||||
|
@ -6,7 +6,7 @@ import dl
|
|||||||
type FNAdder = fn (int, int) int
|
type FNAdder = fn (int, int) int
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
library_file_path := os.join_path(os.getwd(), 'library$dl.dl_ext')
|
library_file_path := os.join_path(os.getwd(), dl.get_libname('library'))
|
||||||
handle := dl.open(library_file_path, dl.rtld_lazy)
|
handle := dl.open(library_file_path, dl.rtld_lazy)
|
||||||
eprintln('handle: ${ptr_str(handle)}')
|
eprintln('handle: ${ptr_str(handle)}')
|
||||||
mut f := &FNAdder(0)
|
mut f := &FNAdder(0)
|
||||||
|
@ -7,7 +7,7 @@ const (
|
|||||||
vexe = os.real_path(os.getenv('VEXE'))
|
vexe = os.real_path(os.getenv('VEXE'))
|
||||||
cfolder = os.dir(@FILE)
|
cfolder = os.dir(@FILE)
|
||||||
so_ext = dl.dl_ext
|
so_ext = dl.dl_ext
|
||||||
library_file_name = os.join_path(cfolder, 'library$so_ext')
|
library_file_name = os.join_path(cfolder, dl.get_libname('library'))
|
||||||
)
|
)
|
||||||
|
|
||||||
fn test_vexe() {
|
fn test_vexe() {
|
||||||
|
Loading…
Reference in New Issue
Block a user