1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

dl: add a complete tested shared library generation/usage example

This commit is contained in:
Delyan Angelov
2020-12-15 18:22:07 +02:00
parent e3a1756b11
commit 3a9034a0d0
6 changed files with 105 additions and 23 deletions

View File

@@ -267,15 +267,17 @@ fn (mut v Builder) cc() {
// linux_host := os.user_os() == 'linux'
v.log('cc() isprod=$v.pref.is_prod outname=$v.pref.out_name')
if v.pref.is_shared {
mut shared_postfix := '.so'
$if macos {
shared_postfix = '.dylib'
} $else $if windows {
shared_postfix = '.dll'
}
if !v.pref.out_name.ends_with(shared_postfix) {
v.pref.out_name += shared_postfix
}
linker_flags << '-shared'
args << '-fPIC' // -Wl,-z,defs'
$if macos {
v.pref.out_name += '.dylib'
} $else $if windows {
v.pref.out_name += '.dll'
} $else {
v.pref.out_name += '.so'
}
}
if v.pref.is_bare {
args << '-fno-stack-protector'