benny.huo
11/20/2020, 11:28 PMe: /home/bennyhuo/.konan/dependencies/clang-llvm-8.0.0-linux-x86-64/bin/ld.lld invocation reported errors
The /home/bennyhuo/.konan/dependencies/clang-llvm-8.0.0-linux-x86-64/bin/ld.lld command returned non-zero exit code: 1.
output:
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol __environ; recompile with -fPIC
>>> defined in /home/bennyhuo/.konan/dependencies/target-gcc-toolchain-3-linux-x86-64/x86_64-unknown-linux-gnu/sysroot/lib64/libc.so.6
>>> referenced by out
>>> /tmp/konan_temp7652478800042105268/result.o:(kfun:com.soywiz.korio.lang.Environment.$<init>$lambda-0$FUNCTION_REFERENCE$190.invoke#internal)
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol stderr; recompile with -fPIC
>>> defined in /home/bennyhuo/.konan/dependencies/target-gcc-toolchain-3-linux-x86-64/x86_64-unknown-linux-gnu/sysroot/lib64/libc.so.6
>>> referenced by out
>>> /tmp/konan_temp7652478800042105268/result.o:(kfun:com.tencent.easyearn.kotlin.logger.KLoggerNativeConsole#warn(kotlin.String;kotlin.Array<out|kotlin.Any?>...){})
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol stderr; recompile with -fPIC
>>> defined in /home/bennyhuo/.konan/dependencies/target-gcc-toolchain-3-linux-x86-64/x86_64-unknown-linux-gnu/sysroot/lib64/libc.so.6
>>> referenced by out
>>> /tmp/konan_temp7652478800042105268/result.o:(kfun:com.tencent.easyearn.kotlin.logger.KLoggerNativeConsole#error(kotlin.String;kotlin.Array<out|kotlin.Any?>...){})
How can I solve this? Adding '-fPIC' to compilerOpts seems useless. Here is part of my build.gradle.kts:
linuxX64 {
binaries {
compilations.getByName("main") {
val matchInterop by cinterops.creating {
defFile("src/nativeInterop/cinterop/libmatch.def")
compilerOpts("-fPIC")
}
}
sharedLib("match", listOf(RELEASE))
}
}