I have a Kotlin multiplatform project where I link with ICU. To make that work, I have created the following .def file:
headers = unicode/ustring.h unicode/utf8.h unicode/uchar.h unicode/ucnv.h unicode/ubrk.h headerFilter = unicode/* compilerOpts.linux = -I/usr/include -I/usr/include/x86_64-linux-gnu linkerOpts.osx = -licui18n -licuuc -licudata linkerOpts.linux = -L/usr/lib64 -licui18n -licuuc -licudata
This works fine on my Fedora system, but when building on Ubuntu this fails because
linkerOpts.linux is wrong. I need to change the link path to:
This leads me to two questions:
- Why do I have to specify the link path in the first place? Normally this is determined automatically, and different distributions use different paths. In fact, it’s impossible to predict which ones are needed.
- Assuming there are some technical reasons why the link path can’t be set up automatically, how can I add some code that runs during build that computes this path automatically? Basically, I’d need to call out to some code that looks at
ld.so.confto determine which path should be used.
What is the proper way to solve this problem?