How to deal with ld error: 'can not be used when making a PIE object; recompile with -fPIC'?

Thank you both for your answers. POSITION_INDEPENDENT_CODE=True did help but I then faced another problem of abi incompatibility. I’ve fixed the problem by compiling the library separately for each platform.