```ld.lld: error: undefined symbol: SnowboyDetectC...
# kotlin-native
a
Copy code
ld.lld: error: undefined symbol: SnowboyDetectConstructor
>>> referenced by Types.kt:162 (/mnt/agent/work/4d622a065c544371/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/Types.kt:162)
>>>               /tmp/konan_temp7723188199372240336/result.o:(snowboy_SnowboyDetectConstructor_wrapper0)
I'm not exactly sure what to do now. I've looked everywhere. I've dumped the cstubs for the library I'm trying to link and everything seems to be in order. I really don't understand why it says that Types.kt:162 is the one throwing the fit. I looked at that line and its CPointer<T>#getPointer. Not sure if its not able to find information on the types being pointed to in C code or what but I'm kinda at my wits end right now.
That's not the only error message, its for all the functions I call in C.
d
Is this failing for your main or test compilation? Kotlin version? Can I see your def file and target configuration in Gradle?
Which platform are you building for?
a
Building for Windows Linux Subsystem Ubuntu Building for main compilation Kotlin/Native 1.3.61
Copy code
headers = /mnt/d/snowboy/examples/c/snowboy-detect-c-wrapper.h
staticLibraries = snowboy-detect-c-wrapper.a libsnowboy-detect.a
libraryPaths = /mnt/d/snowboy/examples/c/ /mnt/d/snowboy/lib/ubuntu64
compilerOpts = -I/mnt/d/snowboy/include
linkerOpts = -L/mnt/d/snowboy/examples/c/snowboy-detect-c-wrapper.a
That is for snowboy
Copy code
headers = /mnt/d/snowboy/examples/c/portaudio/include/portaudio.h \ /mnt/d/snowboy/examples/c/portaudio/src/common/pa_util.h \ /mnt/d/snowboy/examples/c/portaudio/src/common/pa_ringbuffer.h \ /mnt/d/snowboy/examples/c/portaudio/src/common/pa_stream.h
compilerOpts.linux = -I/mnt/d/snowboy/examples/c/portaudio/include/ -I/mnt/d/snowboy/examples/c/portaudio/src/common
That is for port audio
I should elaborate that I'm building for linux x86_64
d
Aha! You've linked your c wrapper correctly but you haven't linked in the cpp library.
It's found the C function but it can't find the C++ function that the C function is calling.
a
That's what I was fearing was happening. Unfortunately I do not have access to the snowboy implementation so that's not gonna be happening. Fortunately, my project does not require Kotlin/Native so I can make peace with just using regular C/C++. Thank you.
d
You don't need the implementation (source code wise), just the
.a
or
.so
file.
Your code wouldn't link in C/C++ anyway, if you don't have the implementation.
a
What I meant was, I have the .a file, its provided to me on the snowboy github repo, the problem is that the .a is built out of C++ and as far as I'm aware, K/N does not like C++ at all. I've been suffering all day with trying to get this to work and nothing has worked and I've honestly settled already with just using C. There's a fully working C demo on the repo that I can use and works just fine for me
d
Was the C++
.a
built with Clang or Gcc? (To be fair, C++ doesn't like C++ either).
a
I don't know. Again, the source code is private. As far as I can tell, it may be gcc. Also, the
.a
is built for ubuntu64 which also kinda concerns me but honestly it shouldn't be a problem for any linux distro since anything built for ubuntu is also built for X where X is some linux based os, but I could be wrong. Right now, I think it's best I come back to this later. I just need to get something working.
j
i think nm -l might get you a list of symbols to examine the libc bindings and see the compilation macros embedded