https://kotlinlang.org logo
#kotlin-native
Title
# kotlin-native
n

natario1

12/06/2023, 11:22 AM
I’m bundling a static library in a Kotlin project with cinterop, then making a shared library out of it. I noticed that public symbols from my C code are also exported in the final binary. Is there any way to avoid that?
j

Jan Holešovský

12/07/2023, 7:03 AM
It's possible to tell the linker to hide symbols; but not sure on which level you want to do it, and what is the best for you. But in my project, I have this in by build.gradle.kts:
Copy code
freeCompilerArgs += listOf("-linker-options", "-S -x -exported_symbols_list " + file("libs/exported-symbols.list").toString())
"man ld" could help you to see the format of exported_symbols_list etc.
n

natario1

12/08/2023, 4:47 PM
Thanks a lot Jan! That should do the job 🙏