Hi, anybody tried to use libevent with kotlin ? I'...
# kotlin-native
k
Hi, anybody tried to use libevent with kotlin ? I'm interested mostly in evhttp and I have some problems with creating bindings. Maybe someone already have working def file ? 😉
d
Let's work through the problems!
k
So first of all I installed libevent and libevent-dev on my linux machine. Than I added a config to my gradle
Copy code
compilations.main.cinterops {
                evhttp {
                    defFile project.file("evhttp.def")
                    packageName 'evhttp'
                    compilerOpts '-I/usr/include -I/usr/include/x86_64-linux-gnu'
                }
my def file atm looks like:
Copy code
headers = evhttp.h
headerFilter = evhttp.h
package = evhttp
During compilation i'm getting
fatal error: 'evhttp.h' file not found
which is a bit strange for me
d
I'm guessing you've checked that
/usr/include/evhttp.h
exists.
k
yup
d
Hmm, that is strange.
Try moving the
compilerOpts
to def file.
k
that didn't helped ... but if I replace
compilerOpts
in gradle with
includeDirs.allHeaders("/usr/include", "/usr/include/x86_64-linux-gnu")
it goes further ...
Oh ... only some warnings and build was successful 🙄
d
😄
k
Ehhh sorry to bother you 😛
n
Does the
includeDirs.allHeaders
function pickup all headers recursively?
k
this is what I found in docs on koltinlang.org:
Copy code
// Directories for header search (an analogue of the -I<path> compiler option).
includeDirs.allHeaders("/usr/include", "/usr/include/x86_64-linux-gnu")

// A shortcut for includeDirs.allHeaders.
includeDirs("include/directory", "another/directory")

// Additional directories to search headers listed in the 'headerFilter' def-file option.
// -headerFilterAdditionalSearchPrefix command line option analogue.
includeDirs.headerFilterOnly("path1", "path2")
👍 1
I guess this is recursive
d
No it does not pick up all headers recursively. Otherwise you wouldn't have to specify the header yourself.
k
What I mean if you have a.h which includes b.h both will be added for bindings creation.
d
Oh sorry. Yes, it does do that recursively.